--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
this. apply_xml(xml). process_changes(message_id). store_model. clear_changes
end
endS.apply_xml(xml, state)))S.process_changes message_id,S.store_model(S.clear_changes(alias State, as: SYou can sort of chain it (really just nesting it) without doing this, but it ends up backwards right. So yes probably harder to follow. And you still have your subject last in your method definitions, which is also backwards if they aren't a record accessor. You might have something like:def apply_xml(message_id, xml, state) do
Oh nice, I'd missed that!
And with the pipeline operator it becomes more elegant and easier to read:xml |>S.apply_xml(state) |>S.process_changes(message_id) |>S.store_model |>S.clear_changes
--
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/aBzymSRUnFY/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to elixir-lang-co...@googlegroups.com.
This won't work because process _changes takes the state as its last argument.More importantly, for the same reason the |> doesn't work well with generated modifiers in records (update_).
I can't reorganize the functions which Record module generates, namely the my_record.field(new_value), my_record.update_field(…)
>> Regardless, I think it would be worthwhile to add `>|`. This will solve two issues - Invoking Erlang libraries, and explicit syntax for accessing the "fast" non-polymorphic record functions.
>>
>> I'm opening an issue for this.
I like this as well, as you and Sasa point out it would have other uses beyond "solving" record pipelining. It is still a little suboptimal in my opinion; after all you could use the .dot operator to chain through parts of your pipeline that include record updates. The disadvantage of doing that is you are using an operator at the end of a statement that depends upon the parameter order of the function in the expression following it. If you rearrange your pipeline you must change this operator. This is why I didn't even suggest it as a workaround but how this would look is:
MOD.do_something(a_record, a_value) |>
MOD.something_else(another_value).
a_field_of_a_record(new_value) |>
MOD.yet_another_thing(ya_value)
All the new operator buys is this:
MOD.do_something(a_record, a_value) |>
MOD.something_else(another_value) >|
MOD.a_field_of_a_record (new_value) |>
MOD.yet_another_thing(ya_value)
Maybe looks a little cleaner, but does not edit any better - just try moving line two to follow line 3.
I would really hope that such a small community of a new programming language could achieve a consensus on programming idioms of this importance. I actually sort of agree with Sasa, but I would not want to see a lot of libraries spring up, half of which use tuple modules all over the place and half of which do not. Because of the parameter ordering problem you cannot as a user of that library blithely substitute one style of usage for the other.
The next obvious step from what Sasa is doing is to make "defobject" and "defm"(method) macros which can cart around arbitrary state in a HashDict (or something) for you. You still have problems though with deep-nesting and likely other issues that led Jose away from OO style in .5. So I would like to hear more about that from him.
Personally, I find all of this inferior to the OO like technique:this.op_1(...).op_2(...)....Therefore I wonder why Jose advised against it, especially since he uses a similar approach himself, for example in the Dynamo project to manage the connection state.Personally, after initial experiments in Elixir, I have settled with this OO like approach and after two years of pain, I have finally found it easy to handle complex state and complex mutations of it in a functional programming language.
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/aBzymSRUnFY/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to elixir-lang-co...@googlegroups.com.