Arc Forumnew | comments | leaders | submitlogin
3 points by ylando 5253 days ago | link | parent

   I will explain:
   1) I think we should separate the definition and the
   assignment some thing like:
   use strict; 
   my x; # declare var for the first time
   x=3;  # assign a value to a var
   in perl.
   3) Suppose we want to make an object oriented
   function; we can write a function
   (def myfunc (this arg1 arg2) ...)
   If we had alias we could write a macro that expand to
   (w/alias (var this.var var2 this.var2)
   (def myfunc (this arg1 arg2) ...))


3 points by rocketnia 5253 days ago | link

1) I think you're missing the whole point of 'let.

  arc> (= x 5)
  5
  arc>
    (let x 3         ; "declare" a var with value 3
      (= x (* x x))
      (+ x 2))
  11
  arc> x
  5
If you want to separate the declaration from the initial value... why? What happens if you use the variable in between those two times?

2) For what it's worth, my Lathe library provides a certain sort of namespaces, and I've been using those pretty happily. (http://arclanguage.org/item?id=11610) But of course I'd be happy with them, 'cause I'm their author. :-p

3) Why would you need a macro to expand to...

  (w/alias (var this.var var2 this.var2)
    (def myfunc (this arg1 arg2)
      ...))
...when it could already expand to something like this?

  (def myfunc (this arg1 arg2)
    (with (var this!var var2 this!var2)
      ...))
That said, I think 'symbol-macro-let would be nifty. I wonder if it could be even more useful to have some way to build a lambda whose free variables were treated in a custom way (as opposed to just being globals). Either one of these could be a basis for scoped importing of namespaces.

-----

4 points by zck 5253 days ago | link

So w/alias is like let, but any changes are shadowed back to where the alias came from?

So

  (let var (cons 1 2)
    (w/alias head car.var
      (= head 2))
    var)
would output

  (2 . 2)
This seems related to macros and backquoting, although I can't quite explain it.

-----