From: Andrew Green Date: 2007-04-24T02:25:33+09:00 Subject: Re: Arrow operator with dash instead of equals (->) El lun, 23-04-2007 a las 09:52 +0900, Gary Wright escribi�: > > o is there no way to make '->' an operator and define its behavior? > > No. Ruby does not support user defined operators. > > > If not, what about '=>'? > > No, '=>' is not an operator in Ruby. > > Many thanks for your replies, everyone... I'll explain briefly why I'm asking: We're working on a domain-specific language that is mainly declarative but that includes little snippets of executable code. These snippets are, at least in our first implementation, in Ruby. In some of the non-executable parts of the language we declare rules for traversing segments of a graph using an arror (->). For example: author -> place_of_birth or sibbling -> children -> age It would be really, really nice to be able to use this same syntax in the executable Ruby snippets, more or less along the lines of: (x -> last_names).to_s + ", " + (x -> first_names).to_s Using a dot instead of an arrow here is not an option for various reasons. Any ideas as to how to hack around this limitation in Ruby, then? Our interpreter eventually gets the code blocks as strings, so I could just substitute the -> for >> behind the user's back, but that would be messy, because it would substitute all occurrences of ->, even if they're in quotes or interpretable by Ruby in some other, unforseen way. Or is there some clean way of doing this? With ri or something similar, maybe? Thanks again, Andrew ---------- (For anyone curious about what we're doing here, here are some links (in Spanish): http://200.67.231.185/mediawiki/index.php/Pescador:Recursos_para_desarrolladores http://durito.nongnu.org/ )