www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Positive

reply bearophile <bearophileHUGS lycos.com> writes:
Having two ways to do the same thing is generally very bad. So what you suggest
is acceptable only as a *replacement* for the old syntax.

The ! is useful, because for me it means "instantiate real code from this
template!", it's a command to do an action. While the dot syntax looks too much
like method invocation and the like.

So I too add my -1 vote to the dot syntax. I think we are about at -20 now, I
presume you have had the (negative) answer from the community.

And next time I suggest you to ask people first. In the design of a language
I've seen it's very easy to add personal quirks.

Regarding the font to use, I suggest you Inconsolata, it's free and it's the
best looking I have seen so far:
http://www.levien.com/type/myfonts/inconsolata.html

Bye,
bearophile
Oct 05 2008
next sibling parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
bearophile wrote:

 Having two ways to do the same thing is generally very bad.

Depends on your view of the world, that. http://en.wikipedia.org/wiki/TIMTOWTDI --anders
Oct 05 2008
parent bearophile <bearophileHUGS lycos.com> writes:
Anders F Björklund:
 bearophile wrote:
 Having two ways to do the same thing is generally very bad.

Depends on your view of the world, that. http://en.wikipedia.org/wiki/TIMTOWTDI

If this is the original motto: "There is more than one way to do it" then its opposite is probably: "There should be one way to do it." But that's not what the Python Zen says, it says: "There should be one—and preferably only one—obvious way to do it." There are two differences: - "preferably" means it's not a hard rule - "obvious" means that there can be other ways, but the obvious one is generally one. This detail is quite important. I have tried both Perl and Python and I like Python better; it allows me to very quickly write correct programs, while I don't like Perl, and I find lot of Perl programs around a mess. So I honestly think it's better for D to adopt that zen rul of Python instead of the one of Perl. The blurb of D refers to Ruby and Python but not to Perl:
D is a systems programming language. Its focus is on combining the power and
high performance of C and C++ with the programmer productivity of modern
languages like Ruby and Python. Special attention is given to the needs of
quality assurance, documentation, management, portability and reliability.<

One example. In D this can be the obvious way to create an associative array that maps strings to their extended ASCII value: void main() { int[string] d; foreach (i; 0 .. 256) d["" ~ cast(char)i] = i; } In Python there are tons of ways to do that, but in Python3 the obvious one is: d = {chr(i): i for i in range(256)} It's short, readable enough, and it's easy to write it correctly the first time. (in Python chars are strings of len 1). In Python2.5 that code was different: d = dict((chr(i), i) for i in xrange(256)) That syntax can be used in Python3 too, but it's not the best way to do it anymore :-) Bye, bearophile
Oct 05 2008
prev sibling next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
bearophile wrote:
 Having two ways to do the same thing is generally very bad. So what
 you suggest is acceptable only as a *replacement* for the old syntax.

I agree.
 The ! is useful, because for me it means "instantiate real code from
 this template!", it's a command to do an action. While the dot syntax
 looks too much like method invocation and the like.

I agree.
 So I too add my -1 vote to the dot syntax. I think we are about at
 -20 now, I presume you have had the (negative) answer from the
 community.

I think it would be nice if the community first tried the syntax. I myself wrote Tuple.(int, int) a couple of times and was like, hmm, that's bizarre. Then I sed my entire codebase and I was in for a treat.
 And next time I suggest you to ask people first. In the design of a
 language I've seen it's very easy to add personal quirks.

You got the timings reversed. How can anyone know how it feels without actually using it? It's a syntax matter, so you gotta see it.
 Regarding the font to use, I suggest you Inconsolata, it's free and
 it's the best looking I have seen so far: 
 http://www.levien.com/type/myfonts/inconsolata.html

Thanks. Andrei
Oct 05 2008
parent reply "Bent Rasmussen" <IncredibleShrinkingSphere Gmail.com> writes:
Quite possibly you just want to avoid the distraction of having it look 
different from a function call. So the dot is more discrete, but is still 
there. This will be a fight to the death against hungarian notation lovers 
and the rest.

- Bent

"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> skrev i meddelelsen 
news:gcaibn$dmm$3 digitalmars.com...
 I think it would be nice if the community first tried the syntax. I myself 
 wrote Tuple.(int, int) a couple of times and was like, hmm, that's 
 bizarre. Then I sed my entire codebase and I was in for a treat.

 And next time I suggest you to ask people first. In the design of a
 language I've seen it's very easy to add personal quirks.

You got the timings reversed. How can anyone know how it feels without actually using it? It's a syntax matter, so you gotta see it.
 Regarding the font to use, I suggest you Inconsolata, it's free and
 it's the best looking I have seen so far: 
 http://www.levien.com/type/myfonts/inconsolata.html

Thanks. Andrei

Oct 05 2008
next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Bent Rasmussen wrote:
 Quite possibly you just want to avoid the distraction of having it look 
 different from a function call. So the dot is more discrete, but is 
 still there. This will be a fight to the death against hungarian 
 notation lovers and the rest.

I wish the dot wasn't even needed. One day I want to go over with Walter about the ambiguities incurred by simply using parens. Andrei
Oct 05 2008
parent Don <nospam nospam.com.au> writes:
Andrei Alexandrescu wrote:
 Bent Rasmussen wrote:
 Quite possibly you just want to avoid the distraction of having it 
 look different from a function call. So the dot is more discrete, but 
 is still there. This will be a fight to the death against hungarian 
 notation lovers and the rest.

I wish the dot wasn't even needed. One day I want to go over with Walter about the ambiguities incurred by simply using parens. Andrei

I'd love to know what the issues are. Using parens alone would be a huge win. (I'm not convinced about a{int} though. I've had no problems with a!(int) ).
Oct 07 2008
prev sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Bent Rasmussen wrote:
 Quite possibly you just want to avoid the distraction of having it look 
 different from a function call. So the dot is more discrete, but is 
 still there. This will be a fight to the death against hungarian 
 notation lovers and the rest.

I wish the dot wasn't even needed. One day I want to go over with Walter about the ambiguities incurred by simply using parens. Andrei
Oct 05 2008
parent reply Michel Fortin <michel.fortin michelf.com> writes:
On 2008-10-05 12:10:36 -0400, Andrei Alexandrescu 
<SeeWebsiteForEmail erdani.org> said:

 I wish the dot wasn't even needed. One day I want to go over with 
 Walter about the ambiguities incurred by simply using parens.

Replacing !( with .( doesn't make things better to my eye. Having only parenthesis would be great though, it it could be disambiguated. - - - I did a quick search and replace in the D/Objective-C bridge, which is pretty heavy in templates, to get an idea of what it would be like using ".(". In many places, the result seems fine: const char[] encode = "{" ~ typename.(T) ~ "=" ~ encode.(size_t) ~ encode.(ArrayType.(T)*) ~ "}"; const char[] encode = "{" ~ typename!(T) ~ "=" ~ encode!(size_t) ~ encode!(ArrayType!(T)*) ~ "}"; I'd be tempted to see the first version, using the .( syntax, as easier to read. But note that here I'm not using a dot for anything else. If I take these other real examples from various lines in the bridge code: mixin objc.bridge.ObjcSubclass.(this.stringof); ObjcSubclassDefs.(T).objcMethodLists ~= ObjcSubclassDefs.(SUPER).objcMethodLists; alias objc.msg.sendSuper.(objc.type.ObjcType.(R), objc.type.ObjcTypeTuple.(A)) msgSendSuper; objc.subclassinit.ObjcSubclassDefs.(typeof(this)).objcClassInit.(typeof(super))(); Here the dot is used to get to symbols in various modules an template members and in conjunction with an opening parenthesis to instanciate templates. This results in the strange "Template.(param).member" syntax. Am I the only one to find that syntax strange... if not misleading? I think all these examples are much better with the current syntax, because defining parameters and accessing members is done with a totally non-overlapping syntax: mixin objc.bridge.ObjcSubclass!(this.stringof); ObjcSubclassDefs!(T).objcMethodLists ~= ObjcSubclassDefs!(SUPER).objcMethodLists; alias objc.msg.sendSuper!(objc.type.ObjcType!(R), objc.type.ObjcTypeTuple!(A)) msgSendSuper; objc.subclassinit.ObjcSubclassDefs!(typeof(this)).objcClassInit!(typeof(super))(); Basically, I believe the syntax we choose needs to convey that we're defining parameters, not accessing a member. I don't really care if we ditch "!(", but I think ".(" is a worse alternative. -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Oct 05 2008
parent Alix Pexton <alixD.TpextonNO SPAMgmailD.Tcom> writes:
Michel Fortin wrote:
 On 2008-10-05 12:10:36 -0400, Andrei Alexandrescu 
 <SeeWebsiteForEmail erdani.org> said:
 
 I wish the dot wasn't even needed. One day I want to go over with 
 Walter about the ambiguities incurred by simply using parens.

Replacing !( with .( doesn't make things better to my eye. Having only parenthesis would be great though, it it could be disambiguated. - - - I did a quick search and replace in the D/Objective-C bridge, which is pretty heavy in templates, to get an idea of what it would be like using ".(". In many places, the result seems fine: const char[] encode = "{" ~ typename.(T) ~ "=" ~ encode.(size_t) ~ encode.(ArrayType.(T)*) ~ "}"; const char[] encode = "{" ~ typename!(T) ~ "=" ~ encode!(size_t) ~ encode!(ArrayType!(T)*) ~ "}"; I'd be tempted to see the first version, using the .( syntax, as easier to read. But note that here I'm not using a dot for anything else. If I take these other real examples from various lines in the bridge code: mixin objc.bridge.ObjcSubclass.(this.stringof); ObjcSubclassDefs.(T).objcMethodLists ~= ObjcSubclassDefs.(SUPER).objcMethodLists; alias objc.msg.sendSuper.(objc.type.ObjcType.(R), objc.type.ObjcTypeTuple.(A)) msgSendSuper; objc.subclassinit.ObjcSubclassDefs.(typeof(this)).objcClassIni .(typeof(super))(); Here the dot is used to get to symbols in various modules an template members and in conjunction with an opening parenthesis to instanciate templates. This results in the strange "Template.(param).member" syntax. Am I the only one to find that syntax strange... if not misleading? I think all these examples are much better with the current syntax, because defining parameters and accessing members is done with a totally non-overlapping syntax: mixin objc.bridge.ObjcSubclass!(this.stringof); ObjcSubclassDefs!(T).objcMethodLists ~= ObjcSubclassDefs!(SUPER).objcMethodLists; alias objc.msg.sendSuper!(objc.type.ObjcType!(R), objc.type.ObjcTypeTuple!(A)) msgSendSuper; objc.subclassinit.ObjcSubclassDefs!(typeof(this)).objcClassIni !(typeof(super))(); Basically, I believe the syntax we choose needs to convey that we're defining parameters, not accessing a member. I don't really care if we ditch "!(", but I think ".(" is a worse alternative.

After seeing these examples I actually think that the dot-syntax kinda works for me. Its like seeing the template as an aggregate of all its possible instantiations and the params in brackets is the "member" that you are after. I never really liked the pling-syntax (when I am coding, pling means NOT) so to keep my code cleaner looking I had a lot of aliases for my templated types, even if they were only used once. I think I could live with the dot. A...
Oct 06 2008
prev sibling next sibling parent reply Alix Pexton <alixD.TpextonNO SPAMgmailD.Tcom> writes:
bearophile wrote:
 Having two ways to do the same thing is generally very bad. So what you
suggest is acceptable only as a *replacement* for the old syntax.
 
 The ! is useful, because for me it means "instantiate real code from this
template!", it's a command to do an action. While the dot syntax looks too much
like method invocation and the like.
 
 So I too add my -1 vote to the dot syntax. I think we are about at -20 now, I
presume you have had the (negative) answer from the community.
 
 And next time I suggest you to ask people first. In the design of a language
I've seen it's very easy to add personal quirks.
 
 Regarding the font to use, I suggest you Inconsolata, it's free and it's the
best looking I have seen so far:
 http://www.levien.com/type/myfonts/inconsolata.html
 
 Bye,
 bearophile

Good programming fonts are hard to find, Vera which Andrei mentioned has a really distinctive lower-case-L which in my opinion is one of the most important features. The lower-case-L is inconsolata is still a little too similar to the numeral-one. A...
Oct 05 2008
next sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Alix Pexton wrote:
 bearophile wrote:
 Having two ways to do the same thing is generally very bad. So what 
 you suggest is acceptable only as a *replacement* for the old syntax.

 The ! is useful, because for me it means "instantiate real code from 
 this template!", it's a command to do an action. While the dot syntax 
 looks too much like method invocation and the like.

 So I too add my -1 vote to the dot syntax. I think we are about at -20 
 now, I presume you have had the (negative) answer from the community.

 And next time I suggest you to ask people first. In the design of a 
 language I've seen it's very easy to add personal quirks.

 Regarding the font to use, I suggest you Inconsolata, it's free and 
 it's the best looking I have seen so far:
 http://www.levien.com/type/myfonts/inconsolata.html

 Bye,
 bearophile

Good programming fonts are hard to find, Vera which Andrei mentioned has a really distinctive lower-case-L which in my opinion is one of the most important features. The lower-case-L is inconsolata is still a little too similar to the numeral-one.

I like the name though. Seduced, abandoned... ready for consolation :o). Andrei
Oct 05 2008
prev sibling parent Derek Parnell <derek psych.ward> writes:
On Sun, 05 Oct 2008 15:34:56 +0100, Alix Pexton wrote:

 Good programming fonts are hard to find, Vera which Andrei mentioned has 
 a really distinctive lower-case-L which in my opinion is one of the most 
 important features. The lower-case-L is inconsolata is still a little 
 too similar to the numeral-one.

I agree. I modified Courier so that it would clearly distinguish between lowercase L and digit 1, zero and letter-O, plus I liked a fatter lowercase-A too. Vera is nice. -- Derek Parnell Melbourne, Australia skype: derek.j.parnell
Oct 05 2008
prev sibling parent "Bent Rasmussen" <IncredibleShrinkingSphere Gmail.com> writes:
Not using it, but it looks quite nice and homogeneous to me

http://www.fsd.it/fonts/pragma.htm

- Bent

"bearophile" <bearophileHUGS lycos.com> skrev i meddelelsen 
news:gca9d3$2ur9$1 digitalmars.com...
 Having two ways to do the same thing is generally very bad. So what you 
 suggest is acceptable only as a *replacement* for the old syntax.

 The ! is useful, because for me it means "instantiate real code from this 
 template!", it's a command to do an action. While the dot syntax looks too 
 much like method invocation and the like.

 So I too add my -1 vote to the dot syntax. I think we are about at -20 
 now, I presume you have had the (negative) answer from the community.

 And next time I suggest you to ask people first. In the design of a 
 language I've seen it's very easy to add personal quirks.

 Regarding the font to use, I suggest you Inconsolata, it's free and it's 
 the best looking I have seen so far:
 http://www.levien.com/type/myfonts/inconsolata.html

 Bye,
 bearophile 

Oct 05 2008