-
As you probably know Clarity official documentation says that map definition should look like this: We know that tuples can be defined also with curly braces, therefore we use following syntax: and our maps are defined like this:
@friedger pointed out that we could use a simplified syntax that does not require defining names in tuples. If we would use it our code would look like this:
And maps usage would change from this:
into something like this:
Syntax is shorter but less explicit. What I would like to know what are your preference when it comes to maps definition syntax? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Good point of discussion and nicely framed :) I prefer the shorter syntax and I disagree that it's "less explicit" just because it's less wordy. I actually find it more explicit since it better resembles Should this be a @labs3/standards discussion though instead of a daoOS discussion? Either way, we may need to update the standards there if this results in a change of policy. |
Beta Was this translation helpful? Give feedback.
Good point of discussion and nicely framed :)
I prefer the shorter syntax and I disagree that it's "less explicit" just because it's less wordy. I actually find it more explicit since it better resembles
map
usage in other programming languages. For other languages, you don't provide an argument of {key: keyName} to a map call, you just pass thekeyName
and the method signature already knows it's the key. I found it confusing when I was first learning clarity that a tuple representing the key is passed as an argument to basic map calls. Seemed wordy, confusing, and unconventional.Should this be a @labs3/standards discussion though instead of a daoOS discussion? Either way, we may need to…