emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with recursive destructive function


From: Eric Abrahamsen
Subject: Re: Help with recursive destructive function
Date: Sat, 28 Jul 2018 16:59:08 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Michael Heerdegen <address@hidden> writes:

> Eric Abrahamsen <address@hidden> writes:
>
>> After weeks of avoiding this, I'm nearly there. This version does
>> everything I need it to, EXCEPT I have somehow lost the ability to
>> handle single-atom data, which was the whole point of passing in a
>> gv-ref. I don't understand why [...]
>
> Did this really ever work like this?  Because, you said you want to
> alter the given data.  If you pass the function a string, and you really
> want to alter that string, you can't just call `upcase' because that
> returns a new string.  You would have to write a function that alters
> the string itself.  You could also return a new string, but then there
> is no need for `gv-ref'.

Pretty sure it did work, in effect it was doing this:

(defun upcase-ref (ref)
  (cl-callf upcase (gv-deref ref)))

(let ((tree "one"))
  (upcase-ref (gv-ref tree))
  tree)

Which for some reason the larger function is not doing any more. I'm not
sure if it's necessary, but for instance I will have to be able to
replace a list (representing an object constructor) into an actual
object, which I assume is equivalent to this string upcase example.

I also realized that I cleverly replaced cl-flet with cl-labels so that
I could recursively transform values that need to be transformed
multiple times... forgetting that the whole point of this was to make it
iterative, not recursive. I suppose I can go back to cl-flet and a
`while' loop.

I'm kind of regretting getting myself stuck in this quagmire!

Eric



reply via email to

[Prev in Thread] Current Thread [Next in Thread]