Lazy eval

Stewart Gordon smjg_1998 at yahoo.com
Fri Aug 25 04:26:59 PDT 2006


Chris Nicholson-Sauls wrote:
> Stewart Gordon wrote:
>> Frank Benoit wrote:
<snip>
>>> This is the first example, showing a ambiguity
>>> func( char[] a ) vs. func( char[] delegate() dg )
>>
>> If one overload matches exactly, it goes without saying that that's 
>> the one that's called.  As such, the programmer would do
>> 
>>     func("qwert");
>> 
>> to call the first, and
>> 
>>     func({ return "qwert"; });
>> 
>> to call the second.  Just like in any other case.
> 
> That's what I would have thought as well, but its already been said that 
> these cases are considered ambiguous...  For example, the following code:

Said by whom, where exactly?  Moreover:

http://www.digitalmars.com/d/function.html

"In D, function overloading is simple. It matches exactly, it matches 
with implicit conversions, or it does not match. If there is more than 
one match, it is an error."

The irony is that this seems to be a case of what this sentence says, 
rather than what it was actually supposed to mean.

<snip>
>> The '=>' doesn't look anything like an array initialiser either.  
>> Unless there's some other kind of array initialiser that I haven't 
>> discovered yet....
>> Wasn't it obvious that I was talking about the bit to the left of 
>> those two characters?
> 
> The only thing I can think of is the PHP format:
> # $foo = array(
> #   'Alpha' => 3 ,
> #   'Beta'  => 6
> # );

Well I don't speak PHP, so no wonder I didn't think of that.

> As far as I know, the D way is to use a colon (:) for this sort of 
> thing.  Although the bit on the left doesn't look like an array 
> initialiser either, in terms of D, as they use brackets rather than braces.
> # const int[] foo = [3, 6, 9] ;
<snip>

Of course!  I'm normally more fluent in D than to confuse these 
notations.  So a struct initialiser is what it looks confusingly like.

Stewart.

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:-@ C++@ a->--- UB@ P+ L E@ W++@ N+++ o K-@ w++@ O? M V? PS- 
PE- Y? PGP- t- 5? X? R b DI? D G e++++ h-- r-- !y
------END GEEK CODE BLOCK------

My e-mail is valid but not my primary mailbox.  Please keep replies on 
the 'group where everyone may benefit.



More information about the Digitalmars-d mailing list