New library: open multi-methods
Jean-Louis Leroy via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Mon Jul 17 23:58:10 PDT 2017
On Tuesday, 18 July 2017 at 02:22:15 UTC, Jay Norwood wrote:
> An excerpt statement from this wiki page is :
> " dynamically dispatched based on the run-time (dynamic) type
> or, in the more general case some other attribute, of more than
> one of its arguments"
>
>
> Based on the 'some other attribute', I wonder if the library
> could conceivably be extended to dispatch based on the User
> Defined Attribute info
>
> https://dlang.org/spec/attribute.html
>
> @('c') string s;
> pragma(msg, __traits(getAttributes, s)); // prints tuple('c')
For example, CLOS allows you to specialize on a value (google for
"eql specialize"). IIRC Clojure allows you to specify your own
dispatcher.
As for specializing on D attributes, I don't think it's feasible.
They are a purely compile-time mechanism. In your example, the
type of "s" is "string", not "@('c') string".
J-L
More information about the Digitalmars-d-announce
mailing list