From: ZB on
Dnia 30.05.2010 Donal K. Fellows <donal.k.fellows(a)manchester.ac.uk> napisa�/a:

> Your big issue is going to be dealing with existing code which uses -> and <-
> for other purposes.

The symbol chosen is not that important; can be just underscore as well, if
it isn't used already other way.
--
Zbigniew
From: Alexandre Ferrieux on
On May 30, 2:41 am, ZB <zbTHIS...(a)ispid.THIS-NOcom.pl> wrote:
>
> % evalThis  {expr {2+2}} -> {set abc {expr {<- + 3}}} -> y

No, in my notation only the toplevel [] of your original example must
be transformed into {}, to avoid too early substitution. Once that is
done, all the Tcl code inside works as usual. So, deeper [] must be
kept:

% evalThis {expr {2+2}} -> {set abc [expr {<- + 3}]} -> y

works as ewpected.

-Alex

From: ZB on
Dnia 30.05.2010 Alexandre Ferrieux <alexandre.ferrieux(a)gmail.com> napisa�/a:

> No, in my notation only the toplevel [] of your original example must
> be transformed into {}, to avoid too early substitution.

Oh, yeah... indeed. So to avoid potential problems, now there's a need
for other characters as "operators".
--
Zbigniew
From: ZB on
Dnia 30.05.2010 Donal K. Fellows <donal.k.fellows(a)manchester.ac.uk> napisa�/a:

> issue is going to be dealing with existing code which uses -> and <-
> for other purposes. For example, I use -> in [regexp] quite a bit as
> the variable name for the whole-string match where I only really want
> the substring matches...

1. But, actually, how can I met such problem, when evalThis procedure
is doing analysis only of my expressions, not going any "deeper"?

2. Even, if so - did you use, for instance, single and double underscore?
I think, it can be good replacement for these "arrows".
--
Zbigniew
From: Alexandre Ferrieux on
On May 30, 10:46 pm, ZB <zbTHIS...(a)ispid.THIS-NOcom.pl> wrote:
> Dnia 30.05.2010 Alexandre Ferrieux <alexandre.ferri...(a)gmail.com> napisa³/a:
>
> > No, in my notation only the toplevel [] of your original example must
> > be transformed into {}, to avoid too early substitution.
>
> Oh, yeah... indeed. So to avoid potential problems, now there's a need
> for other characters as "operators".

No. Your novel syntax requires a different order of substitution, at
least that some parsing be executed before toplevel command
substitution occurs; for this reason, the commands passed to it must
be inside {}. But once that is done, again, the code inside is
absolutely unchanged Tcl code, apart from the rather superficial
substitution of "<-".

Here is the corrected code. Tell me what's not satisfactory in your
eyes (apart from the two aforementioned digressions from the initially
wanted syntax):

proc funnysyntax args {
upvar _stack _stack
set _stack {}
foreach a $args {
switch -glob $a {
-> {lappend _stack $_val}
*\ * {regsub -all {<-} $a {[pop _stack]} a;set _val
[uplevel 1 $a]}
* {uplevel 1 "set $a \[pop _stack\]"}
}
}
}

proc pop vv {
upvar $vv v
set ret [lindex $v end]
set v [lrange $v 0 end-1]
return $ret
}

-Alex