Re: [TCLCORE] Variable access
by Larry McVoy other posts by this author
May 13 2008 7:19AM messages near this date
Re: [TCLCORE] Variable access
|
Re: [TCLCORE] Variable access
> > Unless it's done consistently and properly documented. The current
> > situation is no more consistent on this point, with its mixture of
> > pass-by-value and pass-by-name conventions.
>
> It is! Everything is pass-by-value (pass-by-name is something else
> entirely). Some commands expect values directly for some arguments
> and variable names for other arguments. They never expect either for
> the same argument.
Um, I think the inconsistency being mentioned is this:
set n [gets $f buf]
You just have to know that gets wants one value ($f) and one name (buf).
You are correct, they are both passed by value, but gets does an implicit
upvar on buf so it is sort of a reference.
Lots and lots of people get bit by this in tcl and you really do have to
go memorize which ones do what. It's quite annoying. In my opinion,
a little syntatic sugar like
set n [gets $f &buf]
would be mucho nicer.
--
---
Larry McVoy lm at bitmover.com http://www.bitkeeper.com
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Tcl-Core mailing list
Tcl-Core@[...].net
https://lists.sourceforge.net/lists/listinfo/tcl-core
Thread:
fbonnet
fredericbonnet
Neil Madden
fbonnet
Neil Madden
fbonnet
Lars Hellstrom
fbonnet
Neil Madden
fredericbonnet
David Welton
fbonnet
David Welton
Larry McVoy
Alexandre Ferrieux
Andreas Leitgeb
fbonnet
Neil Madden
Donal K. Fellows
Alexandre Ferrieux
Larry McVoy
Neil Madden
Gustaf Neumann
Neil Madden
Larry McVoy
Neil Madden
Alexandre Ferrieux
fbonnet
Neil Madden
Alexandre Ferrieux
Donal K. Fellows
Larry McVoy
Alexandre Ferrieux
Donal K. Fellows
Alexandre Ferrieux
|