D and the world

eao197 eao197 at intervale.ru
Wed Apr 25 11:57:02 PDT 2007


On Wed, 25 Apr 2007 02:26:48 +0400, Walter Bright  
<newshound1 at digitalmars.com> wrote:

> Don Clugston wrote:
>> I think Nemerle will suffer from this. IMHO, being able to define 'for'  
>> in the language itself, has no benefit in practice; the set of useful  
>> control constructs is very well known. If it's useful to everyone, it  
>> should be rigidly controlled by the language; otherwise you get  
>> confusion and incompatibility.
>> I suspect that in D, metaprogramming will be used almost exclusively  
>> for domain-specific languages.
>
> I agree that too much flexibility in a language is a bad thing. Imagine  
> if you could redefine everything in D. Taken to the limit, that means  
> that every random sequence of characters could be a valid program! This  
> is just not useful.

I'm affraid there is some point of misunderstanding of possible usages of  
metaprograming in languages like Nemerle. Just take DSL as example.  
Nemerle allows to include DSL with different syntax into ordinary Nemerle  
program. For example try to imagine inclusion of ASN.1 fragment[1] into  
code:

     ASN1 class OrderForStock ::= SEQUENCE {
       order-no INTEGER,
       name-address BranchIdentification,
       details SEQUENCE OF SEQUENCE {
          item OBJECT IDENTIFIER,
          cases INTEGER },
       urgency ENUMERATED {
          tomorrow(0),
          three-day(1),
          week(2)
       } DEFAULT week,
       authenticator Security-Type
     }

where 'ASN1' is start of Nemerle syntax macro**.

This is not far away from using CTFE and mixin in the current D version,  
for example:

mixin(Asn1Class( `
     OrderForStock ::= SEQUENCE {
       order-no INTEGER,
       name-address BranchIdentification,
       details SEQUENCE OF SEQUENCE {
          item OBJECT IDENTIFIER,
          cases INTEGER },
       urgency ENUMERATED {
          tomorrow(0),
          three-day(1),
          week(2)
       } DEFAULT week,
       authenticator Security-Type
     }` ) )

But Nemerle allow to use all power of language in macro processing (for  
example it is possible to open and read files in compile-time, connect and  
gather information from remote servers (for WSDL processing and etc),  
retrieving DB schemas, loading precalculated data from somewhere).

What D can answer to that power?

Or may be ASN.1 is not a DSL for which D's mixin is meant for?

[1] An example from John Larmouth "ASN.1 Complete"  
(http://www.c7.com/ss7/books/ASN1_Complete.pdf, page 48)

** I don't know could it be written exactly that way, may be it would be  
necessary to enclose some part of it into quotes.

-- 
Regards,
Yauheni Akhotnikau



More information about the Digitalmars-d mailing list