Open larskanis opened 5 years ago
Maybe an alternative could be to wrap arguments into some special monad that sneeks the value past the sanitization. The obvious downsides are that this has to be done when calling the method, so it'd be a bit less convenient.
Thank you both for your reviewing!
I did a bit of google'ing before picking the € sign for this task. The following Wikipedia topic (section "Entry methods") got me the impression, that almost every keyboard layout has a shortcut for the € symbol: https://en.wikipedia.org/wiki/Euro_sign . Isn't that true?
Just to clarify: Marking values as to be wrapped not only works with positional arguments but also with optional and keyword arguments as well as splat and double splat variables. They all can be marked on a per argument basis.
Alternative solutions to the € symbol could be:
_value
, but _
already has the specialty of not being warned if not used. So this would be an unwanted implication.w_value
or wrapped_value
. But it doesn't look intuitive to me.°
, §
and µ
as first class symbols on the keyboard. But I think they aren't any better than the €
symbol when it comes to international support.async_call :value, def enq(value)
async_call def enq(value, copy: false)
. This mixes Eventbox options into the users method signature, so that it's difficult to divide them apart.Eventbox#shared_object
(although they don't have exactly the same semantics). However the intention behind €-arguments is just to avoid wrapping on the caller side.async_call [:value, :something], def foo(value, bar, something)
# do some stuff here
end
@DarkWiiPlayer Yes that doesn't look too bad. I added a comma to my and your example, which looks ugly, but is required to make it valid ruby syntax. Another variation of this proposal is using a hash:
async_call value: :wrap, something: :wrap, M: def foo(value, bar, something)
# do some stuff here
end
This is more verbose, but also more expressive and could allow other kinds of argument processing beneath deep copies and and argument wrapping in the future. Something like :unsafe
passing of values (for performance etc).
The uppercase key M: def foo
avoids possible conflicts with argument names (arguments must be lowercase).
How about using $EUR$
as a pentagraph for €
?
It's a bit like the trigraphs in the C language but in a more readable form.
@SamSaffron: Hi Lars,
I had a quick look at eventbox, my #1 piece of feedback is that
€value
notation is massive problem. Most non european keyboards don't even have an easy way of entering this. Highly recommend you come up with something else if possible, even an extra param, I don't know.enq(val, copy: true)
or just enq(val.dup)