Does D have too many features?

Timon Gehr timon.gehr at gmx.ch
Sun Apr 29 06:29:21 PDT 2012


On 04/29/2012 02:17 PM, foobar wrote:
> On Sunday, 29 April 2012 at 11:23:17 UTC, Timon Gehr wrote:
>>
>> break can be used as an optimisation to stop execution of a loop that
>> performs a 'reduce' if the result cannot change after a certain point.
>> I use continue mostly for 'filter'-ing out elements from consideration.
>>
>
> Well, I'll use a filter to filter out elements.... :)
>

The filter condition is not always conveniently expressed in terms of a 
lambda function.


>> ...
>> The current way enums can be used as manifest constants is a
>> generalization as well. The generalization takes place on the static
>> semantics level instead of on the conceptual level though.
>>
>
> A language is the interface between a human programmer and a computer
> and should IMO provide clear conceptual level abstractions for the
> benefit of the human. I realize that using enum for manifest constants
> makes sense on the implementation level but I feel the compiler should
> work for me and not the other way around.
>

Well, I don't think that 'enum' for manifest constants asks a lot from 
the programmer, but YMMV.


> ...
> macro testMacro() {
>  std.writeln("Hello world!");
>  <| std.writeln("Hello world!"); |>
> }
>
> macro is a syntactic sugar on top of a regular function. You can call it
> just like you call a regular function. The first line is executed
> regularly and the second one is mixed-in [returned token stream from the
> macro]
> since the macro is evaluated by the compiler, the first line would
> generate compile-time output. the second line would be part of the
> generated code and would be thus executed during run-time of my code.
>
> Regarding syntax, the main difference is that it's a token stream and
> not text but otherwise pretty much the same as current CTFE. The
> important difference here is the execution model which is different from
> CTFE.
>

We have the 'macro' keyword ;). Probably it should just be a built-in 
primitive type of the language that represents an AST?







More information about the Digitalmars-d mailing list