-
Notifications
You must be signed in to change notification settings - Fork 55
Expression sub-language for modifying state #143
Comments
How about something like ...
|
I like it! One issue is what does
We could imagine something like the following, which would provide a lot more flexibility as to how the user specifies what to remove:
|
Another question, is whether those new operations should replace the current |
For types that have I do like the How about |
@dselman I am not sure if we have a mechanism to check the unicity of identifiers at the moment? And they aren't distinguished from other attributes in Ergo (yet?) -- technically there isn't any object equality in Ergo, only value equality. You could easily use the
If we keep both forms, I think the |
For the records, @kach had suggested the nice and compact:
And add/remove can technically be handled using array operations:
|
I like the brevity of this suggestion, but would rather avoid introducing another operator. With this in mind what about ... ?
This aligns the syntax for state assignment with assignment in let expressions. |
There is a nice syntax in F# (OCaml Dotnet variant) that does something like this |
I like the idea of conveying cloning since this could be used outside of setting state. I don’t know why I didn’t think of this. And of course the ocaml/f# syntax is quite nice for that. Note that things are a bit more difficult in Ergo since we need those operations to be aware of the “class hierarchy”, not just records as in OCaml. A branch is tracking this, but I still need to work through the typing ramifications. |
Is there a level of meta-programming or reflection on types ? |
Not in Ergo itself if I understand your question correctly. Although you can use match expression on type names which are declared as part of the hierarchy. |
In JavaScript, we can use the spread operator for cloning. This might be a good syntax in Ergo as well?
|
Nice. You can even save typing by using & instead |
Doesn't seem that obvious to a less technical user. |
@dselman that was also the impression on the Ergo call this morning. I do find a syntax for cloning appealing since it can be applied to things other than the |
The logic is to be able to clone and override any type not just the state. state being here just one case of it. |
…ject#143 Signed-off-by: Jerome Simeon <[email protected]>
…rdproject#143 Signed-off-by: Jerome Simeon <[email protected]>
This is the proposal that has been implemented in #667 Note that this new feature is specific to the state, this does not include support for things like spread operator. |
Signed-off-by: Jerome Simeon <[email protected]>
…rdproject#143 Signed-off-by: Jerome Simeon <[email protected]>
…rdproject#143 Signed-off-by: Jerome Simeon <[email protected]>
…rdproject#143 Signed-off-by: Jerome Simeon <[email protected]>
Implemented in the |
Signed-off-by: Jerome Simeon <[email protected]>
When changing the state, one has currently to rebuild the whole state each time. It might be useful to have expressions specifically designed to modify the state. For instance:
The text was updated successfully, but these errors were encountered: