[erlang-questions] If you are homesick for object.selector

Loïc Hoguin essen@REDACTED
Fri Jan 25 23:35:02 CET 2013


On 01/25/2013 07:26 PM, Fred Hebert wrote:
> On 01/25, Garrett Smith wrote:
>> Let's compare this:
>>
>>    Strength = '?'(Char, [stats,skills,strength])}
>>
>> to this:
>>
>>    Strength = Char.stats.skills.strength
>>
>> Now, which would a beginner prefer? The first version is *terrifying*.
>> And if the programmer *could* brave the syntax, what about all that
>> extra typing?? Just looking at that code makes my fingers tired :(
>>
>> That's why Ruby is #2 on github language ranks and Erlang isn't even
>> in the top 10! [1]
>
> Of course it's terrible. It's a 15 minutes attempt to show it's doable
> to navigate deeply nested data structures. I might as realistically make
> a function that accepts:
>
> Char = set(new, stats,skills,strength, 50)
> Strength = get(Char, stats,skills,strength)
>
> by using parse transforms (you can get list of args and redistribute
> them the way you want, iirc), using my module from the previous e-mail as
> the underlying representation. This can be done as a blind replacement,
> without any new support from the language, with currently existing
> tools, and work on pretty much any reasonable depth. Someone just has to
> go through the trouble of doing it.

That's the point: it should be *built into the language*, you shouldn't 
have to go through the trouble of doing something like this. And it 
should be *obvious* and in line with the rest of the language. I quite 
like the xpath idea Darach mentioned. It could integrate very well with 
the rest of the language. I might experiment with it.

-- 
Loïc Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu



More information about the erlang-questions mailing list