heinrichmartin <
martin....@frequentis.com> wrote:
> On Friday, February 20, 2015 at 3:02:08 AM UTC+1, Aidan Hobson Sayers wrote:
> > Of course :) I'm just entertaining myself with Tcl corner cases.
> > [...]
> >
> > Yes, I have observed that the Tcl parser (when playing with it in
> > C) always gives me one empty command at the end of a script.
> >
> > It's unclear that this is acceptable:
> >
> > > [2] Evaluation.
> > > [...] The first word is used to locate a command procedure to
> > > carry out the command [...]
> >
> > Note 'is'. I think someone reading that description would be
> > forgiven for thinking that a command is at least one word.
> >
> > Aidan
> Entertaining not only yourself ...
> expect:~$ [lindex {} 0]
> empty command name ""
> while evaluating {[lindex {} 0]}
> expect:~$ ;# empty command
> expect:~$ proc {} {} {;# empty}
> expect:~$ [lindex {} 0]
> expect:~$ {}
> expect:~$
What version of expect is this? My version here gives this instead:
expect1.1> [lindex {} 0]
ambiguous command name "": _close.pre_expect after append apply array
auto_execok auto_import auto_load auto_load_index auto_qualify binary
break case catch cd chan clock close close_on_eof concat continue
coroutine debug dict disconnect encoding eof error eval exec exit
exp_close exp_close_on_eof exp_configure exp_continue exp_debug
exp_disconnect exp_exit exp_fork exp_getpid exp_inter_return
exp_interact exp_internal exp_interpreter exp_log_file exp_log_user
exp_match_max exp_open exp_overlay exp_parity exp_pid exp_remove_nulls
exp_send exp_send_error exp_send_log exp_send_tty exp_send_user
exp_sleep exp_spawn exp_strace exp_stty exp_system exp_timestamp
exp_trap exp_version exp_wait expect expect_after expect_background
expect_before expect_tty expect_user expr fblocked fconfigure fcopy
file fileevent flush for foreach fork format getpid gets glob global
history if incr info inter_return interact interp interpreter join
lappend lassign lindex linsert list llength lmap load log_file log_user
lrange lrepeat lreplace lreverse lsearch lset lsort match_max namespace
open overlay package parity pid proc prompt1 prompt2 puts pwd read
regexp regsub remove_nulls rename return scan seek send send_error
send_log send_tty send_user set sleep socket source spawn split strace
string stty subst switch system tailcall tclLog tell throw time
timestamp trace trap try unknown unload unset update uplevel upvar
variable vwait wait while yield yieldto zlib
while executing
"[lindex {} 0]"
> The error message should definitely be changed to invalid command
> name "".
Why should it be changed? The name "", if defined, is a valid command
name:
% proc "" {args} {puts "Empty command name called, with args '[join $args ", "]'"}
% "" a b c d e f
Empty command name called, with args 'a, b, c, d, e, f'
%
% {} zxy abc
Empty command name called, with args 'zxy, abc'
%
Provided one does not exclude zero length words, a zero length word is
a member of the general set "words". Just as a set of zero elements is
a proper set in mathematics. And a zero length list is also a proper
list to Tcl.
"" is valid to expect as well:
expect1.2> proc "" {args} {puts "Empty command name called, with args '[join $args ", "]'"}
expect1.3> [lindex {} 0]
Empty command name called, with args ''