-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
[Enh]: Missing Evaluation API & Tests #14439
base: Pharo12
Are you sure you want to change the base?
[Enh]: Missing Evaluation API & Tests #14439
Conversation
- `Symbol>>#cull:cull` - used in Magritte and will make packaging much easier - `Symbol>>#valueWithEnoughArguments` - already implemented by Object, Block, and MessageSend; make polymorphic with those
Proposed for Pharo 12: pharo-project/pharo#14439
I’d love that! |
I approved but I let open to have other opinions here |
I do not like. I do not see the added value.
|
I find it confusing.
I do not see the point of creating an array to place the receiver in, just for the sake of executing it.
|
@seandenigris @jecisc it would be nice if you better document the usage. I understand there is a need, it would be good for the community if you tell us what are examples of usages! @seandenigris there are no such messages in object :) @Ducasse I understand you don't like it, I personally have no strong opinion. But if there is a community need, that's important too. My main arguments here are:
This said I'm personally for more minimalistic APIs: less to maintain, easier to work with. But if we go full that way I'd like to clean a lot of collection methods. |
Yes! We are on the same page. When you know how many arguments you have and need, this would not be used. The only reason that I know of to use this somewhat convoluted method is to have a generic way to plug together loosely coupled components. This sort of thing is often needed in Magritte for example. Here's an example... Let's say I have an So now, we have The only problem is that there is one missing implementation - Symbol. Once that is added, one can supply an Object or any common evaluatable in a case such as the one above. Also, please note that I'm not suggesting this be used in Pharo Core, only that it be provided along with the other implementors. Please let me know if that was helpful or if there's any other info I can provide. |
This is ok. I understand the point with the block API. I never like the hijack of symbol as a block. |
Personally I find the code way more readable using the symbols than a block that will just send one unary message. classes collect: [ :class | class name ] vs classes collect: #name When I read it, with the second I have the impression of reading english while the first one gives me the impression to read code. And the block is taking more time to my brain to understand (It's not a lot, but it still impacts). As Guille said, it's not to use in Pharo. We can have a rule of not accepting that in Pharo itself. But for external projects it would make thing much more easier. |
@guillep The use cases are to let the users configure some objects. I have for example one MDL component that hold a selected object in it and the user can configure a tooltip based on this object. So we want the user to me able to just write selectWidget tooltip: #description But! in some edge cases, the user whats to customize way more things and in that case he needs the canvas of Seaside to do something such as:
Because of this edge case, either we cannot use symbols (but it makes the code in the framework more readable) or we need to check the type of the parameter and the number of arguments ourself. So it's easier to add our own #cull:cull: in Symbol. I had this case in multiple of my projects. |
I have plenty of examples showing that using a symbol instead of a block totally obscure the code because we have no way to know if this is a symbol or a disguided block. I do not want to get started there. |
This discussion is interesting! Given that:
I'm wondering if the opposition is to the PR, which aims to provide needed functionality for external libraries and their users, or just an interesting academic discussion? |
Hi @seandenigris I don't think there is a need to be condescending either. I understand there is no need to use it in the kernel. On the other side, controlling that no users are introduced will be an active job for maintainers doing code reviews, writing rules, tests, running those in the CI... I think the discussion is whether the cost of having it inside (and having to maintain it, optimize it, and so on) is worth the gain you're going to have. In that sense, maybe it would be nicer to have a small project in pharo-contributions that holds all these and other extensions. We can even move the extraneous one from Pharo there. Then magritte, material design lite, and others could depend on that if needed. |
I'm not doing academic discussions here. I'm trying to understand
Now my personal take:
So sorry to be slow to think. |
I have a question why can we use perform
there you can mix symbols and blocks.
|
Is a MessageSend object not better? I think that we should remove the load on Symbols. |
That was not my intention. I’m sorry if it seemed that way. I sincerely was asking whether the discussion was related to accepting this PR or more generally about these techniques, because this is not a new feature. Perhaps academic was a poor word choice, since it can have negative connotations.
Not at a computer, but I think because it’s not implemented by Object. A common use case is to allow either lazy evaluation (e.g. a block) or the actual object you want. MessageSend is an interesting idea. Let me play with that |
For my own education if you will indulge me…
Isn’t that more of a documentation issue? It is common for a block to be passed in one place and used in another. Unless there is a method comment explaining the arguments, one is lost
In that regard, what is the difference between
That’s interesting. I don’t know about that. What are the ramifications? |
In fact I would like to remove Object>>valueWithArguments: because I do not understand why it is there. |
I know adding value and cull API can be a controversial rabbit hole (e.g.
#value:value:value:value:value:value:value:value:value:
), but of the two methods I'm proposing, the first will greatly simplify Magritte packaging and the second makes Symbol polymorphic with all the other similar receivers. I hope that you will consider them. I even wrote tests, lol!Symbol>>#cull:cull
- used in Magritte and will make packaging much easierSymbol>>#valueWithEnoughArguments
- already implemented by Object, Block, and MessageSend; make polymorphic with those