[its-hackers] Muddle function to remove a node from a list.

Jack Haverty jack at 3kitty.org
Mon Apr 12 01:01:25 CEST 2021


It's been a very long time since I wrote Muddle code.   But IIRC you
need to think about what happens in various cases, especially the one
where the node to be removed is the first one in a list.  A main issue
is what parts of the original list may be already "pointed to" by some
other data structure or variable.  Depending on how you actually "remove
a node", those other objects may end up still pointing to the original
list elements.   The node you "remove" won't actually disappear until
nothing else points to it, and the garbage collector sees it as collectable.

If the caller has the node to be removed, and has the list, it doesn't
really need anything returned except maybe a #FALSE if the node isn't
actually in the list.   Most important is to document exactly how the
code "removes a node" so it's possible to judge its effects before
writing code to use a "general purpose remover".

I don't remember exactly how OBLIST works, so it may not matter for that
particular list.  But if "general purpose" means other kinds of lists,
it probably does.

Enjoy Muddle!
/Jack Haverty
MIT-DM 1971-1977


On 4/11/21 1:25 PM, Eric Swenson wrote:
> My opinion only and not necessarily based on any well-founded principles or precedents:
>
> It should return the mutated list. The caller already has the node that was removed (having passed it as an argument), but in order to perform further operations on the mutated list, having your function return it allows callers to invoke functions on the result of calling your function — rather than having saved a reference to the before-mutated list in a local variable, and then having to perform tour side-effecting function, ignoring the result, and having to referenced the saved reference to the now-mutated list.
>
> -- Eric
>
>
>> On Apr 11, 2021, at 11:53, rrs0 at earthlink.net wrote:
>>
>> Hi Lars, and muddle hackers,
>>
>> While working on the ITS Muddle Package System, I found a need for function that removes a
>> Node from .OBLIST. SO I wrote a general purpose node remover that modifies the original
>> List. My question is my function more useful if it returns the List or the  node it removed??
>>
>>        Rick
>>
>>




More information about the its-hackers mailing list