Hi Christophe,

> Is it possible to shortcut the value resolution of transient
> symbols with a custom function? Something like:

I'm not sure I understand the question.

The value of symbols (not only transients) is the CDR of the cell
representing the symbol. The evaluator of the interpreter fetches this
value, i.e. a single pointer-indirection.


> (de shortcut_transient (name)
>   (pack name "!"))
> This would add a "!" to the default value of a transient sym.

So something like

   (set MyTransient (pack "!" (val '"MyTransient")))

would do? Full example:

: (setq MyTransient "abc")
-> "abc"

: (set MyTransient (pack "!" (val '"MyTransient")))
-> "!MyTransient"

: MyTransient
-> "abc"

: (val @)
-> "!MyTransient"


Or, for a more general usage, you might consider using methods on
objects to achieve a more configurable, flexible behavior.



> BTW I had a related question (maybe for many months!):
> Is there a PicoLisp function/mechanism like «unknown» in Tcl:
> http://wiki.tcl.tk/795

You could 'catch' such errors

   (catch '("Undefined")
      ... )

but this is not completely the same.

A built-in handler for undefined functions exists, but only if the
symbol name contains a colon, e.g. 'lib:foo', then the interpreter looks
for a shared library 'lib' and there for a symbol 'foo'.



> Some context for the reason I need this kind of transient
> manipulation (for the curious and because maybe I'm trying
> to solve the wrong problem):
> I'm embedding a language in Picolisp. I managed to build
> Blockly blocks for this language:
> http://microalg.info/ide.html (click on «Commandes»,

Nice! :)


> For this I need to produce XML from Lisp code. This is quite
> easy considering that the data is not data but some source code.
> The trick is to reprogram my language so that each command
> will output some XML recursively (thanks to Lisp!!!).
> ...
> And more generally (and this is the problem I post about), I need
> "any transient sym" to dynamically have the value  (based on its name):

Hmm, so is this the same as the localization does in PicoLisp? Transient
symbols representing strings in the application are kept in a global
structure '*Uni', and are assigned a new value (i.e. the translation in
the target language) by the 'locale' function.



> I note that this transient thing is VERY powerful. Alex, could you
> provide us with some historical hindsight about transient syms? Do
> they exist in other languages? Are they your brainchildren?

Transient symbols are just normal symbols, except that they have a
file-local scope, and happen to look lexically like strings in other
languages. That's all.

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

Reply via email to