Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • "list" is already a function name, so I wouldn't use it as a variable. This wouldn't happen if the language had sigils...
    • That's why you have quoting... er... that's why function application only applies to the first element of a cons... er... that's why you have Lisp-2... er... sigils are ugly, darnit.

      • Incidentally, Lisp uses the @ sigil for list interpolation.  Example:

        (let ((foo '(1 and 2)))
          `(this is a new list with ,@foo in it))

        That evaluates to (this is a new list with 1 and 2 in it).  It amuses me anyway :)
    • This isn't a problem. Symbols get their values from different "slots" depending on context. When you write (list 'foo 'bar), list is called as a function. When you write (setq list 42) and then (+ list list), you get 84. It's very clear. The only problem is calling a function saved in the value slot of a symbol: (defun foo (a b) (- a b)) (let ((foo (lambda (a b) (+ a b)))) (foo 2 1) ; 1 (funcall foo 2 1)) ; 3 Oh well, you can't have everything.
      • Ugh, apologies for the worthless formatting.
      • This isn't a problem.

        ... not for the compiler anyway. Some of the rest of us like to optimize for the slower parts of the process, often known as wetware.

        • FWIW, Perl suffers from this problem, sort of:

          sub foo {}
          my $foo = sub {};
          my $foo = "hello";
          $foo->(); # death

          Anyway, lisp is what it is.  It's straightforward to write a macro such that:

          (with-sigils (&foo) (foo $foo))

          expands to

          (progn (funcall foo) (foo foo)))

          If you really care I'll try it out and blog the code :)
      • Disclaimer: the last Lisp I used was AutoLisp...many years ago. I don't remember if it behaved the way you describe or not. I later (after posting) figured this wouldn't be a problem in this instance anyway because "list" was (dynamically?) scoped to the function. But I still don't think I'd call a variable "list" in the language (w/o sigils) :-)