Foreach on a template?

Robin Allen r.a3 at ntlworld.com
Mon Mar 12 18:11:11 PDT 2007


I thought the person I was replying to was telling me it couldn't accept 
templates because of the grammar. If I was wrong about that and Daniel 
was just saying that it *doesn't* accept templates: I know, that's what 
I was asking to have changed.

-Rob


Jarrett Billingsley wrote:
> "Robin Allen" <r.a3 at ntlworld.com> wrote in message 
> news:et1cch$2gmi$1 at digitalmars.com...
>> Okay, I should have said they *should* mean the same thing. Or that the 
>> programmer using foreach would *mean* the same thing. Anyway, acording to 
>> the spec, foreach expects an 'expression' which can be pretty much 
>> anything, so there's no reason why a template shouldn't work.
> 
> Just because it expects an expression doesn't mean it should be able to 
> handle *any* expression.  What about
> 
> foreach(x; 5)
> 
> ?  That makes no sense.
> 
> The grammar of foreach just defines what can come there syntactically.  It's 
> the semantics that determine what's _legal_ there. 
> 
> 



More information about the Digitalmars-d mailing list