[metapost] Using |s| as a variable name
nicola
vitacolo at dimi.uniud.it
Wed Dec 5 12:23:03 CET 2007
Hello,
I am a bit puzzled by the way a name like |s| may behave. Why is this
seemingly correct:
string s;
s = "aaaaaaa";
|s| = length s;
show |s|;
and why does the following produce an error?
string s;
s = "aaaaaaa";
|s| = length s;
for i = 1 upto |s|:
;
endfor;
>> |s|:
! Improper final value has been replaced by 0.
I would like to use |s| in a subroutine, as follows:
vardef foo(expr x) =
|x| := length x;
enddef;
string s;
s = "abc";
foo(s);
end;
Why is this not possible? Isn't |x| a valid sequence of tags?
Nicola
More information about the metapost
mailing list