From: isambart@... (Vincent ISAMBART) Date: 2004-03-16T17:39:44+09:00 Subject: Re: Embedding Ruby, part 2 Joe Mason wrote in message news:... > In article <20040315092252.09144.00001411@mb-m14.aol.com>, GGarramuno wrote: > >>1000.times() > >>{ > >> a = ls(:type => b) > >>} > >>It would be more like standard Ruby and will certainly will be simpler > >>to do. > > > > Sadly, it's not a good solution, for a bunch of reasons. > > MEL has over 200 commands just like "ls", all allowing multiple dash options. > > These tend to change/be added among Maya versions, too. The syntax above more > > or less implies I'll be parsing the options myself, which is insane work and > > kind of silly as MEL will do its own error checking for those. > > FYI, you can convert symbols (like :type) to strings, so it's simple to use > the method_missing command described belore to convert the ruby > parameters ":type => b" to "-type b". That doesn't fix your other two > objections, though. It was the reason why I suggested this solution. But the problem is that after the first parameter with a value, all others must also be given a value... And you cannot just copy/paste the MEL code... But you could easily make in Ruby a MEL to RubyMEL converter (I just hope the order of the arguments is not important. > I worry about the consequences of this. Sounds like a huge security > hole, but I guess if you trust MEL it's not so bad. One problem is you > can't call any MEL functions that are named the same as Ruby methods. > You'll want to keep your general MEL() function for emergencies, at > least. (Just have method_missing convert it's args to a string and then > call MEL() to do the rest of the work.) > > I like the syntax "MEL.ls -type b", but that might mess up the > cut-and-pasting you mentioned. You could use MEL.instance_eval { }, it would allow you to put many lines of code... But the other problems are still there... I do not see how you could use something like ls -type directly in Ruby... I think 'ls -type' will always be seen as ls(-(type)) with type 'beeing' a variable and '-' the minus operator...