Positive
Michel Fortin
michel.fortin at michelf.com
Sun Oct 5 11:38:17 PDT 2008
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.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list