Re: lambda... again



On 23 Okt., 03:22, "slebet...@xxxxxxxxx" <slebet...@xxxxxxxxx> wrote:


The disadvantage is that calling a lambda is different from calling a
regular proc (you need to prepend apply to it). Now... if someone
feels like modifying [unknown] so that lambdas can be called like a
proc.....

Oh, that's easily done:
% proc know what {
if ![info complete $what] {error "incomplete command(s) $what"}
proc unknown args $what\n[info body unknown]
}
% know {
if {[llength [lindex $args 0]]==2} {return [eval [linsert $args 0
apply]]}
}
% set try {{a b} {expr {$a * $b}}}
{a b} {expr {$a * $b}}
% $try 7 6
42
It just conflicts with spaces in command names, so don't do both... :^)

.



Relevant Pages

  • Re: lambda... again
    ... proc lambda { ... set name [list lambda $p $b] ... has all the advantages of regular variables: ... The disadvantage is that calling a lambda is different from calling a ...
    (comp.lang.tcl)
  • Re: Whats wrong with lambda and class
    ... If the lambda is being coerced, it isn't being honest about it: ... The idea that it has to do with yield is basically right, ... class Proc. ... the methodnotation to send a Proc instance to ...
    (comp.lang.ruby)
  • Re: Passing a named function instead of a code block?
    ... grab a method as an object without calling it, ... :square1 is an atomic unit representing the symbol whose ... we call square1 and cast the result of that using '&'. ... '&square2' is fine as square2 is just a variable referring to a proc. ...
    (comp.lang.ruby)
  • Re: When are lambdas needed?
    ... is that lambda treats return, next, and break a little bit differently. ... It's actually a difference between lambda and proc (which are ... lambdas are invoked using the same semantics as a message send. ... Lambdas act like methods in that: ...
    (comp.lang.ruby)
  • SQL Task Error in proc not detected?
    ... I have a package calling a stored proc PROC1, ... proc PROC2, ...
    (microsoft.public.sqlserver.dts)