On 2014-10-30 09:16:34 +0000, "Martin Nowak" <c...@dawg.eu> said:

On Tuesday, 11 March 2014 at 18:23:08 UTC, Jacob Carlborg wrote:
A DIP is available here [1] and the latest implementation is available here [2].

[1] http://wiki.dlang.org/DIP43

Instead of adding the selector syntaxsyntax you could reuse pragma mangle.

Nooo! Mangling is something different from the selector name. Mangling is the linker symbol for the function. The selector is the name used to find the function pointer for a given a dynamic object (with similar purpose to a vtable offset). The function has both a mangled name and a selector name, and they're always two different names.


Alternatively a compiler recognized UDA would work too.

     @objcSel!("insertItemWithObjectValue", "atIndex")
     void insertItem(ObjcObject object, NSInteger value);

Ah, that's better. Except you really should use a single string with colons, otherwise you'll have a problem distinguishing no-parameter selectors from single-parameter selectors.


Changing the lexer and parser would affect all D language tools (editors, formatters, linters, other compilers). So now that we do have UDAs I don't see a justification for changing the syntax and grammar of D.

Very true. I agree. Now that UDAs exist, it'd be preferable to use them.

That said, there are other parts of D/Objective-C that could pose difficulties to existing languages tools, some syntactic (__selector, or "this.class" to get the metaclass), some semantic (overridable static methods having a "this" pointing to the metaclass). I had to bend the rules in some places to make all that work. But it's true that nothing will be more confusing to those tools than the selector declaration currently following a function name.


--
Michel Fortin
michel.for...@michelf.ca
http://michelf.ca

              • R... Jacob Carlborg via Digitalmars-d-announce
              • R... Christian Schneider via Digitalmars-d-announce
              • R... Jacob Carlborg via Digitalmars-d-announce
              • R... Christian Schneider via Digitalmars-d-announce
              • R... Michel Fortin via Digitalmars-d-announce
              • R... Christian Schneider via Digitalmars-d-announce
            • Re: D... Michel Fortin via Digitalmars-d-announce
              • R... Jacob Carlborg via Digitalmars-d-announce
  • Re: D/Objective-C 64bit Martin Nowak via Digitalmars-d-announce

Reply via email to