ch-ch-changes
Don
nospam at nospam.com
Thu Jan 29 02:07:29 PST 2009
Yigal Chripun wrote:
> Andrei Alexandrescu wrote:
>
> [snipped where appropriate]
>
>> String mixins are meant to be used for short functions, which at least
>> in my code there are plenty of. You can e.g. sort by a field by writing
>> sort!("a.name < b.name")(vec) without so much as thinking about it. If
>> you want syntax highlighting, sort!(q{a.name < b.name})(vec) may do (it
>> does in my editor). But then again: almost by definition, if you feel
>> like needing syntax highlighting in a string mixin, that string has
>> outgrown its charter. Use a delegate.
>
> that's a good point but I don't like string mixin to be used for that.
> Actually, string mixins should be deprecated in favor of better tools.
> IIRC, ada has expression generics, which in D would be like:
> sort!(a.name < b.name)(vec) // instead of the above
> the difference is that it's not a string but an expression in the
> language itself.
And you can't do nearly as much with it.
> I want to clarify one point here - the problem with this for IDEs
> (compared to text editors) is not highlighting, this is merely a
> symptom. Unlike a text editor, an IDE understands the code (it works on
> the AST level) and therefore the type of the above is a string and is
> treated as such - it's not treated as the AST representation of the
> expression.
>
[snip]
> 4) AST macro's accept expressions of course. string mixins are obsolete.
I don't believe that an AST macro is ever going to be able to reproduce
the composition power of string mixins. But I agree that we'd like to
remove strings from public interfaces.
More information about the Digitalmars-d
mailing list