4 ms·
Instead of: sig {params(name: String).returns(Integer)} ... why not simply: sig [String]=>[Integer] Yes, that's just ruby - see https://github.com/s6r
by geraldbauer 7y ago
Instead of:
sig {params(name: String).returns(Integer)}
... why not simply:
sig [String]=>[Integer]
Yes, that's just ruby - see https://github.com/s6ruby/ruby-to-michelson/blob/master/contracts/token.rb#L32 https://github.com/s6ruby/ruby-to-michelson/blob/master/cont... for example for live running code (in secure ruby) :-)
- rubyfan 7y agoRuby has named parameters right? In theory signature needs parameter name and wouldn’t be sufficient for all cases to with a simple String in Integer out I think.
- bhuga 7y agoAt the very least, sigs need to be in blocks so they can be lazy and not require that all constants in any sig be loaded at require time. It was a design decision that all type annotation arguments be named as opposed to positional. As one example why, it makes the error messages better. You can always say "You're missing a type declaration for parameter 'foo'" as opposed to "You have four positional arguments and 3 types". We could probably still bikeshed our annotations inside the `sig { ... }`. I'm not sure we'd make constants with unicode like BigMap‹Address→Account› for generics, though, how do you even type that? :)
- geraldbauer 7y agoFor the "do not require" the type annotations / signatures so they can be lazy I would use / recommend a language pragma and not a block. Learn more about language pragmas (works kind like a pre-processor) :-) - https://github.com/s6ruby/pragmas https://github.com/s6ruby/pragmas I think you already have made-up your own "magic comments" / language pragma e.g. # type: true and so on. > I'm not sure we'd make constants with unicode like > BigMap‹Address→Account› for generics, though, how do > you even type that? :) I see you managed to type it! What's your secret? :-). By the way, you can use the alternate ASCII-style e.g. BigMap.of(Address=>Account).
- geraldbauer 7y agoLooking through the online docs. Here's another instead of: sig {params(new_value: T.nilable(Integer)).void} ... why not simply: sig Integer? # or sig [Option.of(Integer)]=>[] # longest form in sruby sig [Integer?]=>[] # same as Integer?