Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. - Augment example ``struct Map(@named alias Function, @named InputType, @named ElementType)`` with a less exagerated signature.
  2.  
  3. ```d
  4. auto map(alias Function, InputType)(InputType input) {
  5. return Map!(Function, InputType)(input);
  6. }
  7.  
  8. struct Map(alias Function, InputType,
  9. @named ElementType = ElementType!InputType)
  10. ```
  11.  
  12. - Python's parameter syntax is not ``identifier = Parameter`` it is ``** Identifier`` and that is only for variadic or unknown keyword arguments, all parameters can be passed in as named.
  13. - C# does not have opt-in syntax for parameters.
  14. - ``It is the author's opinion that the is expression is heavily overloaded and doing too much. It should be possible to access the names of named template parameters outside of an instantiated template, but it should be done with a mechanism other than the is expression.`` is potentially too vein.
  15.  
  16. Add example
  17.  
  18. ```d
  19. void func() {
  20. alias Type = Foo!int;
  21.  
  22. static if (is(Type : Foo!T, T)) {
  23. }
  24. }
  25.  
  26. struct Foo(Type) {
  27. }
  28. ```
  29.  
  30. If the template parameter of Foo was @named, then T in the static if would have to match the name of the parameter.
  31. Which could conflict and the user would be forced to change other parts of the code and not use a name that suits them.
  32. This is a consequence of named parameters being non-positional.
  33. - Walter's proposal should have a section dedicated to it in the form of 'alternative solutions'
  34. - Can you discuss the pros and cons of marking each individual parameter vs marking functions?
  35. - ``The side effect of this decision is that named parameters must be opt-in. Parameters must be marked as accepting named arguments, otherwise there will be no way to determine which overload to resolve.``
  36. Needs to be made clearer that it is related to the previous paragraph.
  37. - ``The @named attribute prevents clashes with other existing language``
  38. Demonstrate what other syntaxes could produce (e.g. T:V vs T::V).
  39. - subset vs sublist, make it clear at both locations what is meant.
  40. - ``Overload resolution for symbols (for function and template``
  41. Use std.traits isInstanceOf as example of code that will need to be changed to accomedate named parameters.
  42. - Semantics heading can get at least one more sub heading split out from it
  43. - Non-eponymous members of eponymous templates are currently inaccessible from outside the template body, so this will require changes to D's name lookup rules.
  44. - Add new section comparing and contrasting reordering rules
  45. - A named parameter requires a name, specify this.
  46. - In place struct initialization syntax: "Just use the syntax I proposed for named parameters. The feature will be disabled if the struct has constructor(s) for it, as now." - Walter
  47. - Make it clear that @named is an attribute (and hence can't be defined for UDA use).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement