motoko icon indicating copy to clipboard operation
motoko copied to clipboard

FR: preserve argument names using Candid named argument types.

Open crusso opened this issue 2 years ago • 0 comments

@letmejustputthishere suggests:

for a method like this

  public query func greet(name : Text) : async Text {
    return "Hello, " # name # "!";
  };

why doesn’t the generated did contain the names for the arguments? e.g.

service : {
  greet: (name: text) -> (text) query;
}

instead of

service : {
  greet: (text) -> (text) query;
}

https://dfinity.slack.com/archives/CPVUFG8UV/p1704194551430229

Claudio Russo I expect it's because the Candid is generated from the internal type representation, not the syntactic types, and those names have been removed. (edited) Moritz Fuller could we change this? imo it would be really helpful to have those annotations in the interface Claudio Russo I don't think it's trivial to change, but would it not be better to just use a record if you want to name the arguments? Moritz Fuller i suggested that as well, but i see no reason why this information should be lost when going from motoko to candid :thinking_face: Claudio Russo Since it's not pertinent to subtyping, we would need to both maintain yet ignore it everywhere. It might be doable though, just awkward to flow through without disturbing things.

crusso avatar Jan 02 '24 15:01 crusso