Hi Erik,

> I know I (ab)use 'fill' / 'macro' too much in my code, but I often want
> to insert (not splice) the result of some calculation. Would you consider
> a new '_' syntax within 'fill' forms?
> 
> : (fill (1 2 _ (+ 1 2))
> -> (1 2 3)

Hmm, I would not be very happy if we invent yet another special symbol, in
addition to the existing '^'. This might even break programs already having data
with '_' symbols.


> This can currently be accomplished a few different ways
> 
> : (let X (+ 1 2) (fill (1 2 X) 'X))
> : (let @X (+ 1 2) (macro (1 2 @X)))

I suppose you mean (let @X (+ 1 2) (fill (1 2 @X))), 'macro' uses 'fill'
internally but then immediately evaluates the result.

> : (fill (1 2 ^ (list (+ 1 2)))

So yes, these are the three variants we currently have for 'fill'.


> The first two are quite verbose for what is usually a simple or concisely
> expressed calculation. The last one is ugly.

I agree with you. Though in reality we often have the desired values already in
variables, so that explicit 'let's are not needed.

But I also would like to have an elegant way to achieve what you described.


> Thoughts?

What about some middle way?

We stick with '^' only, but make it behave more intelligent:

   1. If the result of the evaluation is a list, we get the same result as now.
   2. But if the result is an atom, it is automatically 'cons'ed into a cell.

This would not break any existing programs, as atomic results were useless.

So we would get

   : (fill (1 2 ^(list (+ 1 2)))  # Current semantics
   -> (1 2 3)

   : (fill (1 2 ^(+ 1 2))  # New behavior
   -> (1 2 3)

What do you think?

☺/ A!ex

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to