DMD 0.161 release

BCS BCS at pathlink.com
Wed Jun 21 09:38:03 PDT 2006


Lionello Lunesu wrote:
> BCS wrote:
> 
>> Chris Miller wrote:
>>
>>> On Tue, 20 Jun 2006 02:03:08 -0400, Walter Bright  
>>> <newshound at digitalmars.com> wrote:
>>>
>>>> Mostly bug fixes.
>>>>
>>>> http://www.digitalmars.com/d/changelog.html
>>>
>>>
>>>
>>>
>>> Wow, that new literal delegate syntax is crazy but I like it.
>>>
>> [...]
>>
>> Ohhhh fun!! Try finding the bug in this one (ignore the hints).
> 
> 
> -snip-
> 
> It seems to work just fine here? Prints 2, exactly what I expected :)
> 
>  L.


if about 4 typos are removes it becomes this and returns 1.

<code>
#import std.stdio;
#void main()
#{
#    writef(fn,\n);
#}
#
#int fn()
#{
#  int baz()
#  {
#    return 6;
#  }
#
#  void figNewton( int i, int delegate()fnp=&baz, int k=3, int l=0)
#  {
#  }
#  int w;
#
#  /+
#  figNewton(9,
#  {
#    return 1;
#  },
#  w = (1+3),
#  doNothing);
#  +/
#
#  figNewton(9);
#  {
#    return 1;
#  };
#  w = (1+3);
#  doNothing);
#
#  return 2;
#}
#int doNothing(){return 1;}
</code>

Another not so obfuscated one is this:

#import std.stdio;
#void main()
#{
#  for(int i=0; i<10; i++)
#  (cast(void delegate())
#  {
#    writef("foo");
#    return;
#  }
#  )();
#}

The point is that there could end up being some confusion as to weather 
something is a function or just a block. I think that the last rule gos 
a bit to far. Typing in the "()" doesn't cost much and adds a bunch as 
far as readability goes.


FunctionLiteral
	function Typeopt ( ArgumentList )opt FunctionBody
	delegate Typeopt ( ArgumentList )opt FunctionBody
	( ArgumentList ) FunctionBody
 >>	FunctionBody



More information about the Digitalmars-d-announce mailing list