July 24, 2004 Re: Templates and the '!' | ||||
|---|---|---|---|---|
  | ||||
Posted in reply to Arcane Jill  | In article <cds3re$2qcl$1@digitaldaemon.com>, Arcane Jill says... > >In article <cdrvjf$2md5$1@digitaldaemon.com>, Berin Loritsch says... >> >>I agree. >> >>Foo!(int) >>Foo|(int) >>Foo:(int) >>Foo@(int) >>Foo#(int) >>Foo$(int) >> >>Out of the options listed, I think I like the pipe or colon declarator the best. > >Well, would I be shot down in flames for suggesting this, rather obvious, alternative: > >Foo<int> > >Arcane Jill > > >Well, would I be shot down in flames for suggesting this, rather obvious, alternative: Booo!!! Booooooooooo!!! >>Foo!(int) >>Foo|(int) >>Foo:(int) >>Foo@(int) >>Foo#(int) >>Foo$(int) Pipe is logical OR no ? , colon is label specifier, the others are ugly, i personally like the !. $ <- scalar @ <- array # <- comment! Purple Elephant  | |||
July 24, 2004 Re: Templates and the '!' | ||||
|---|---|---|---|---|
  | ||||
Posted in reply to Elephant  | 
>>>
>Pipe is logical OR no ? , colon is label specifier, the others are ugly, i personally like the !.
>
>$ <- scalar
>@ <- array
># <- comment!
>
>Purple Elephant
This isn't perl-land.   # is not a comment, and $ is not a scalar.  and @ is just for email addresses. :P
 | |||
July 24, 2004 Re: Templates and the '!' | ||||
|---|---|---|---|---|
  | ||||
Posted in reply to Sha Chancellor  | Sha Chancellor wrote: > Why are we using the ! symbol for templates? Couldn't we use a | or something else? # isn't used, neither is @ or $. Actually, # is used for Special Token Sequences: http://www.digitalmars.com/d/lex.html#specialtokens I'm happy with ! but if it were changed, I'd vote for $ above all. -Chris S. -Invironz  | |||
July 24, 2004 Re: Templates and the '!' | ||||
|---|---|---|---|---|
  | ||||
Posted in reply to Sha Chancellor  | On Fri, 23 Jul 2004 14:03:21 -0700, Sha Chancellor wrote: > I just was looking at a piece of code. And while this is largely my problem, I keep reading: > > Foo!(int) > > as Foo not int. > > And thinking what on earth? And then remembering oh yeah templates... > > Why are we using the ! symbol for templates? Couldn't we use a | or something else? # isn't used, neither is @ or $. Okay, I'll bite too! I still have a mental hiccup when seeing all those '!' symbols embedded inside template instances. @Foo(int) is my preference. The '@' signifying that the next token 'Foo' is a template name and the template is now being instantiated, using 'int' as its argument. However, I haven't been able to grok the whole D template system. Every thime I read the docs and examples, I come away even more confused. I've tried a few times to play with them but it still does not make any sense to me. I guess I'm not sure what problems are trying to be solved by them. But I haven't given up yet. ;-) -- Derek Melbourne, Australia  | |||
July 26, 2004 Re: Templates and the '!' | ||||
|---|---|---|---|---|
  | ||||
Posted in reply to Sha Chancellor  | "Sha Chancellor" <schancel@pacific.net> wrote in message news:cds920$2us1$1@digitaldaemon.com... > I think I like the $ as the best alternative also. :P > > Foo$(int) looks good to me. Yeah, but you'd run afoul of all those folks who want to use $ as a synonym for array.length <g>.  | |||
July 26, 2004 Re: Templates and the '!' | ||||
|---|---|---|---|---|
  | ||||
Posted in reply to Berin Loritsch  | "Berin Loritsch" <bloritsch@d-haven.org> wrote in message news:cdrvjf$2md5$1@digitaldaemon.com... > Foo|(int) > Foo:(int) These have parsing ambiguity problems. > Foo@(int) > Foo#(int) > Foo$(int) I try to avoid using characters not in the C set. > The "!" symbol just naturally maps to "not" in many people's minds. "*" piped to multiply in my mind before I started using C <g>.  | |||
July 26, 2004 Re: Templates and the '!' | ||||
|---|---|---|---|---|
  | ||||
Posted in reply to Sha Chancellor  | Sha Chancellor wrote:
> I just was looking at a piece of code.  And while this is largely my problem, I keep reading:
> 
> Foo!(int)
> 
> as Foo not int.
> 
> And thinking what on earth? And then remembering oh yeah templates...
> 
> Why are we using the ! symbol for templates?  Couldn't we use a | or something else?  # isn't used, neither is @ or $.
OK.  Well, how about:
Foo!!(int)
Or even (sorry Walter)
Foo!int!
I suppose I'm getting too Eiffelish here, and Walter doesn't like separated markers.  So I propose
The operator should be !!
It's name should be _instance_  (just in case we ever want to allow it to be overridden).
Spaces before and after it should be optional.  So, probably, should be the parens.  A type argument is required.
 | |||
July 26, 2004 Re: Templates and the '!' | ||||
|---|---|---|---|---|
  | ||||
Posted in reply to Walter  | >I try to avoid using characters not in the C set.
Sorry, but what's the reason ? D is a new language, it's not meant to be compatible with C or C++. Why then restrict to that 30 year old standard ?
OT: If I were making up the syntax, I'd make it use Python-like indentation instead of curly braces but that's just the broken CPU in my head ;)
 | |||
July 26, 2004 Re: Templates and the '!' | ||||
|---|---|---|---|---|
  | ||||
Posted in reply to h3r3tic  | h3r3tic wrote:
> Sorry, but what's the reason ? D is a new language, it's not meant to be
> compatible with C or C++. Why then restrict to that 30 year old standard ?
Ah, but it is meant to be compatible with C at the binary level and, to a lesser extent, at the syntax level. The less you deviate from traditional C syntax the easier it is to learn the language.
 | |||
July 26, 2004 Re: Templates and the '!' | ||||
|---|---|---|---|---|
  | ||||
Posted in reply to Mike Parker  | Mike Parker wrote:
> h3r3tic wrote:
> 
>> Sorry, but what's the reason ? D is a new language, it's not meant to be
>> compatible with C or C++. Why then restrict to that 30 year old standard ?
> 
> 
> Ah, but it is meant to be compatible with C at the binary level and, to a lesser extent, at the syntax level. The less you deviate from traditional C syntax the easier it is to learn the language.
Yet I dont think that foo!(int) is a small deviation from the C syntax. It will seem to C programmers as foo not int. Making it foo@(int) for instance (heh, instance...) would make them think "aaaahh, that's something different!" and reading foo at int, pretty much seems logical as a template specialization. AT reads as SPECIALIZED BY in my mind. But again, I don't think I can make anyone/Walter change the current syntax. Yet I still think that if someone is smart enough to learn C, they would be smart enough to learn some syntax changes.
Anyway, I hope we'll have implicit specializations so I don't have to use foo!(int) too often
 | |||
Copyright © 1999-2021 by the D Language Foundation
 
Permalink
Reply