John Gerdeman on Wed, 03 Sep 2008 15:05:52 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

functions in dot notation


Hello,

I was wondering about the following behavior of functions in dot
notation. Functions in  dot notation, seem to have no problem changing
integers, that are available globally. Trying to let them manipulate
lists, that are equally available fails.

A minimal example follows:

\\!/usr/bin/gp
\\ -*- coding: utf8 -*-
/* Description:
 *
 * Test functionality of functions in dot notation.
 *
 */
integer=1;
 test1()={
 	local(value);
 	value=3;
 	print("    integer before: ",value);
 	integer.function;
 	print("    integer after:  ",value);
 }

 integer.function={
 	value=4;
 }



test()={
	LIST=List([2,2]);
	print("    set LIST to arbitrary value: ", LIST);
	LIST.initialize;
	print("    LIST should now return List([]): ",LIST);
}

LIST.initialize={
 	LIST=listcreate(4);
 }
print("Using a function in dot notation to alter a integer works.");
test1();
print("Using a function in dot notation to alter a List does not
work.");
test();



P.S.: Is there a way to let the mailserver know I'm a real person? I
reply to its validation requests, but it still sends me an email, saying
my message was blocked along with like 5 to 10 registration validation
emails from various sites.