From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2003-03-22T03:24:09+09:00 Subject: Re: Proposal: new operator: '<-' (for assignments) In article <024d01c2efbc$2fa7a040$6401a8c0@MELONBALLER>, Chris Pine wrote: >----- Original Message ----- >foo = Foo.new("this value") >...later... >foo <- "some new value" >---------------------------- > >This looks backwards to me. What I mean is, shouldn't the arrow point the >other way? It seems closer to how hashes literals work, for example. The >"variable" points to the "value". Hmmm... I guess I read it as 'foo takes the value "some new value" > >In any case, I don't think you can have left arrows like <- and <=: <= is >taken (and isn't an arrow :) and <- might be used in code like 'a<-b' (is >`a' less than negative `b'?). Aye, there's the rub... > >So how would you feel about -> ? > >Honestly, I'd be a little surprised if this got in to the language. >Depending on your situation (you're trying to make a special-purpose >language, right?) it might be better to write your own interpreter on top of >Ruby, snarfing generously. > >For example, if you have a string of code like: > > foo << { doSomethingHere } > >you could just split the string on the first '<<' and eval the substrings. >Depending on how robust you need your language to be (I'm assuming not very, >since you were writing it for people who aren't really programmers, IIRC), >this should be a relatively easy task, and perfect for Ruby. There's no >reason the code used has to be readable by the actual Ruby interpreter, if >you can write a couple-hundred line interpreter as a go-between. > I'm specifically trying to avoid writing a parser. I want RHDL to be pure Ruby. I think what I'll end up doing is using '<<' and then alias the original '<<' to 'shiftl'. Phil