-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal to change the assignment operator in ValueSet #17
Comments
I considered using My thinking was that Maybe let's leave this open to see if other people find |
Would it be possible to use dictionary literal syntax to construct this? Syntactically it makes sense: return Insert([
\Task.id: .uuid(),
\Task.createdAt: .now,
\Task.text: text,
\Task.url: url,
]) There's a built in type called |
Unfortunately, this can’t be modeled as a dictionary. Each of the pairs shares a type for the value, which is erased as it enters the array but guarantees that the left- and right-hand side of each assignment is the same. \Task.id == .uuid() // Assignment<Task>
\Task.id // KeyPath<Task, UUID>
.uuid() // Expression<Task, UUID>
== // (KeyPath<Model, Value>, Expression<Model, Value>) -> Assignment<Model> |
@mdiep Why using Maybe
Sounds good. This is the sort of thing were there is not "right answer". |
I guess you can! I didn't think you could redeclare the operator, but it doesn't look like that actually causes issues. 🤔 I think I'd still like to sit on this for a bit. 🤔 |
As I mentioned @mdiep before, I think that using the
==
operator for assignment inValueSet
s is confusing. I think people (or at least in my case) would be confused to see the equality operator being used in such way. I think the==
is one of those operator that you see in almost every programming language so people would probably assume that a comparison is being performed while skimming through the code.The first time I saw the following example I had to pay special attention to how the
Insert
value was constructed.After giving it a second look I assumed that
==
was not being used as the equality operator and then had to read PersistDB's source code to understand howValueSet
works.I think that using
<~
or<-
or<--
or:=
would be better and at least won't be confused with the equality operator at first glance. If I had to pick one I would choose:=
because it is used in other programming languages (like Go or Pascal) as the assignment operator.The text was updated successfully, but these errors were encountered: