From: Jonathan Bromley on
On Fri, 11 Sep 2009 12:33:34 GMT, Don Porter wrote:

>> Every Script Is A List.

>Careful. You got that backwards.

I didn't mean to say anything profound - it was
just flippant. But maybe I'm misunderstanding
something important. Is it possible to have a
script that is *not* a well-formed list?
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley(a)MYCOMPANY.com
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
From: Bryan Oakley on
On Sep 11, 8:49 am, Jonathan Bromley <jonathan.brom...(a)MYCOMPANY.com>
wrote:
> On Fri, 11 Sep 2009 12:33:34 GMT, Don Porter wrote:
> >>  Every Script Is A List.
> >Careful.  You got that backwards.
>
> I didn't mean to say anything profound - it was
> just flippant.  But maybe I'm misunderstanding
> something important.  Is it possible to have a
> script that is *not* a well-formed list?

Yes.

% set script "puts {hello world};"
puts {hello world};
% eval $script
hello world
% llength $script
list element in braces followed by ";" instead of space

From: Jonathan Bromley on
On Fri, 11 Sep 2009 07:07:20 -0700 (PDT), Bryan Oakley wrote:

>On Sep 11, 8:49�am, Jonathan Bromley <jonathan.brom...(a)MYCOMPANY.com>
>wrote:
>> On Fri, 11 Sep 2009 12:33:34 GMT, Don Porter wrote:
>> >> �Every Script Is A List.
>> >Careful. �You got that backwards.
>>
>> I didn't mean to say anything profound - it was
>> just flippant. �But maybe I'm misunderstanding
>> something important. �Is it possible to have a
>> script that is *not* a well-formed list?
>
>Yes.
>
> % set script "puts {hello world};"
> puts {hello world};

D'oh. Of course. Thanks.
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley(a)MYCOMPANY.com
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
From: Ralf Fassel on
* Andreas Leitgeb <avl(a)gamma.logic.tuwien.ac.at>
| Jonathan Bromley <jonathan.bromley(a)MYCOMPANY.com> wrote:
| > set newpath [eval file join $components]
| > # I don't like eval very much....
--<snip-snip>--
| You can, however, treat the arguments to eval such, that it will be
| safe and not all that slow:
|
| set newpath [eval [linsert $components 0 file join]]

Could you explain how the 'linsert' approach is better/safer than the
direct 'eval file join', assuming $components is the result of a
[file split]?

The only problem I can imagine would be with special TCL chars in the
elements:

% set original_path {/foo/[bar]/baz}
/foo/[bar]/baz
% set comp [file split $original_path]
/ foo {[bar]} baz
% eval file join $comp
/foo/[bar]/baz

But 'file split' seems to handle that properly in 8.3 and 8.5...

R'
From: Joe English on
Don Porter wrote:
> Jonathan Bromley wrote:
>> ah, yes, that's nicer. Every Script Is A List.
>
> Careful. You got that backwards.

Neither one is strictly correct:

% set script {set a "[concat "a b" "c d"]"}
% info complete $script
==> 1
% llength $script
==> error "list element in quotes followed by "a" instead of space"

and conversely:

% set list {x [ y}
% info complete $list
==> 0
% llength $list
==> 3

What you can say is: "A canonical-form list, when parsed as a script,
will be interpreted as a single command whose words are the elements
of the list." That's about the only relationship between lists
and scripts I can think of...


--Joe English