Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6015283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:48:51+00:00 2026-05-23T02:48:51+00:00

I recently stumbled over the D programming Language and i really like it. You

  • 0

I recently stumbled over the D programming Language and i really like it. You can programm really high-level while having full Hardware access like in C.

coming from a rather functional background (Haskell,scala) I´m searching for a way to pattern match in D, but i found nothing on http://www.digitalmars.com/d/.
In Haskell pattern matching is supported by the language itself.
In Scala it´s achieved by case classes or extractors(normal objects with an unapply method).

Is it possible to do this in D?

the receive method in std.concurrency which is used to do concurrency in an actor-style like in erlang and scala takes a bunch of functions and pattern matheses on these.
But i think it´s not as flexible as in other languages. Can you uses guards ? Can you extract the Object´s contents like it´s possible in scala ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:48:52+00:00Added an answer on May 23, 2026 at 2:48 am

    No pattern matching as known from Haskell is built in into language, but D has very generic compile time and reflection capabilities that will allow you to match type and their structure in library. For matching runtime values you can use only ordinary if / switch … constructs; lazy evaluation of function arguments might also help with implementation of some matching-at-runtime techniques.

    Template Constraints will allow you to create function (template) overloads based on any expression evaluated at compile time (D allows you to execute almost all normal code during compilation). You can also use static if for similar effect. This will practically allow you to match type structure. This is also commonly used technique in D.

    You might find code of std.algorithm interesting, look for isInputRange and similar functions – they perform matching on type structure – they restrict type of argument to be of certain typeclass

    Some directions for compile time reflection:

    • Is Expression
    • Traits
    • std.traits
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently stumbled upon a cool feature in CVS where you can name revisions
Having recently stumbled across improvements to CSS such as Less and Sass , I
I recently stumbled over this post , which introduces the collect method for Scala
I have recently stumbled over a seeming inconsistency in Python's way of dealing with
Recently I've stumbled over surface. It's incredible and so easy to develop small applications
Recently I stumbled over code such as this: void foo(const Bar* b) { ...
Recently I stumbled over this code snippet in Ruby: @data = 3.chr * 5
I have a fair amount of experience using MOQ, while I've recently have stumbled
Recently I've stumbled upon JONESFORTH , which is an interpreter for the Forth programming
I want to share this odd but interesting situation I stumbled upon recently while

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.