Re: Making a function "forget" a variable



In article <87ve3ht8is.fsf@xxxxxxxxxxxxxxxxxxxxxxxxxx>,
Pascal Bourguignon <pjb@xxxxxxxxxxxxxxxxx> wrote:

Barry Margolin <barmar@xxxxxxxxxxxx> writes:

In article <87zlstt9o6.fsf@xxxxxxxxxxxxxxxxxxxxxxxxxx>,
Pascal Bourguignon <pjb@xxxxxxxxxxxxxxxxx> wrote:

Barry Margolin <barmar@xxxxxxxxxxxx> writes:

In article <7cd4ppvf4t.fsf@xxxxxxxxxxxxxxxxxxxxxxx>,
pjb@xxxxxxxxxxxxxxxxx (Pascal J. Bourguignon) wrote:

Barry Margolin <barmar@xxxxxxxxxxxx> writes:
[...]
Doesn't work if the function needs to update the variable.

Really?

While your technique is certainly cute, I hardly think it's what he
meant by "pass those variables in as function arguments".

That's exactly what's done in C. What would you call that if it was
written in C?

I'd call it passing a pointer to a variable.

Passing a variable: foo(a);

Passing a pointer: foo(&a);

There is no pointer in lisp.
Technically, what I passed wasn't a pointer, but a closure.

Conceptually, both in C and in Lisp we passed a variable.

The point is between passing by value and by reference. I'll bet tar
meant the former when he was making his recommendation. Tar, can you
confirm this?

--
Barry Margolin, barmar@xxxxxxxxxxxx
Arlington, MA
*** PLEASE don't copy me on replies, I'll read them in the group ***
.



Relevant Pages

  • Re: Making a function "forget" a variable
    ... While your technique is certainly cute, I hardly think it's what he ... I'd call it passing a pointer to a variable. ... both in C and in Lisp we passed a variable. ...
    (comp.lang.lisp)
  • Re: segfault w/ block, but not file scope
    ... technique of passing a pointer to an object to allow a function to ... C doesn't "have" linked lists, but in a program using the usual ... technique involving structures and pointers, ...
    (comp.lang.c)
  • Re: [PATCH] [0/9] Use 64bit x86 machine check code for 32bit too
    ... warning: passing argument 2 of ‘strict_strtoull’ makes integer from pointer without a cast ...
    (Linux-Kernel)
  • Re: segfault w/ block, but not file scope
    ... >>> the value of a pointer to emulate pass by reference. ... >> mean it's suddenly a different programming technique. ... > specifically as a syntactic feature of a language. ...
    (comp.lang.c)
  • Re: Critical section shared betwen dll and main program
    ... I am discussing the case of dynamic DLL ... loading and passing PCRITICAL_SECTION between old version of DLL ... and an executable which was build in newer environment. ... without passing a pointer to the kernel32.dll? ...
    (microsoft.public.win32.programmer.kernel)