Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Using a repeated function prefix with different parameter names #84

Closed
gsabran opened this issue Mar 14, 2018 · 2 comments
Closed

Using a repeated function prefix with different parameter names #84

gsabran opened this issue Mar 14, 2018 · 2 comments

Comments

@gsabran
Copy link

gsabran commented Mar 14, 2018

It seems impossible to generate a class with repeated function prefixes:

MyClass  {
  create:1 {
    NSString *username
  }
  create:2 {
    NSString *userId
  }
}

should be able to generate the code

@interface MyClass : NSObject <NSCopying>

+ (instancetype)createWithUsername:(NSString *)username;

+ (instancetype)createWithUserId:(NSString *)userId;

...
@end

but because in the .value file both have the same key create the generation fails with

Algebraic types cannot have two subtypes with the same name, but found two or more subtypes with the name create
@tommycrush
Copy link

You can create what you want like this:

MyClass {
  %singleAttributeSubtype attributeType="NSString *"
  createWithUsername
  %singleAttributeSubtype attributeType="NSString *"
  createWithUserId
}

However, when you match this object, it won't be as clean out-of-the-box (the var will be called "createWithUsername" rather than "username".

But still, good enough.

@gsabran
Copy link
Author

gsabran commented Mar 16, 2018

ok thnaks

@gsabran gsabran closed this as completed Mar 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants