Positive

Alix Pexton alixD.TpextonNO at SPAMgmailD.Tcom
Mon Oct 6 04:10:55 PDT 2008


Michel Fortin wrote:
> On 2008-10-05 12:10:36 -0400, Andrei Alexandrescu 
> <SeeWebsiteForEmail at 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.
> 

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...



More information about the Digitalmars-d mailing list