Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

GAWK implementation (source code) question (change noticed in 3.1.4)
The question has to do with the (new?) type Node_var_new.

I'm curious as to when this type was added and what its purpose is.
I had made some modifications to gawk in earlier versions (maybe 3.0.6) and
did not have to deal with this, but now I tried making the same mods to
3.1.4 and found that if type is Node_var_new, you have to change it to
Node_var - after which all is as before.  Can anyone tell me why this
change was made?


Report this thread to moderator Post Follow-up to this message
Old Post
Kenny McCormack
12-03-04 01:55 AM


Re: GAWK implementation (source code) question (change noticed in 3.1.4)
In article <cod4bc$df5$1@yin.interaccess.com>,
Kenny McCormack <gazelle@accessinter.combat> wrote:
>The question has to do with the (new?) type Node_var_new.
>
>I'm curious as to when this type was added and what its purpose is.
>I had made some modifications to gawk in earlier versions (maybe 3.0.6) and
>did not have to deal with this, but now I tried making the same mods to
>3.1.4 and found that if type is Node_var_new, you have to change it to
>Node_var - after which all is as before.  Can anyone tell me why this
>change was made?

It helps in tracking uninitialized variables and function parameters.
Particularly for function parameters, whose type can change on the
fly:

BEGIN { f(a) }

function f(p) { p[1] = "x" }

Gawk can't tell that global variable `a' is really supposed to be an
array until after f() has run.
--
Aharon (Arnold) Robbins --- Pioneer Consulting Ltd.	arnold AT skeeve DOT com
P.O. Box 354		Home Phone: +972  8 979-0381	Fax: +1 206 350 8765
Nof Ayalon		Cell Phone: +972 50  729-7545
D.N. Shimshon 99785	ISRAEL

Report this thread to moderator Post Follow-up to this message
Old Post
Aharon Robbins
12-03-04 08:56 AM


Re: GAWK implementation (source code) question (change noticed in 3.1.4)
Hi,

> Kenny McCormack wrote: 

Arnold has explained most of it.  I'd like to point out a few gotchas:
 

You should also initialize it to an uninitialized value:
tree->type = Node_var;
tree->var_value = Nnull_string;

This is best illustrated by make_scalar() in eval.c.

Also note that under some circumstances, you may encounter Node_array_ref
where you'd expect Node_var. For example:

function f(x) { x = 1 }
BEGIN { f(a) }

After you enter the function, ``a'' is of type Node_var_new and ``x'' is
of type Node_array_ref.
After the assignment is executed, both are changed to Node_var, since
make_scalar() has been called with the ``x'' node as parameter.

To sum up, you code has to take care of Node_array_ref's, unless you take
care to initialize all variables before passing them to a function.

HTH,
Stepan Kasal

Report this thread to moderator Post Follow-up to this message
Old Post
Stepan Kasal
12-07-04 08:59 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

AWK archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:20 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.