cc: [email protected]
Subject: Re: Re: No static functions in typeset -T xxx=(...) ... / was: Re:
[ast-users] _ doesn't refer to the correct object.
--------
> [snip]
> > # Static method
> > typeset -fS totalpop
> > function totalpop {
> > printf 'Total population is currently %d.\n' "${_.po
> lation}"
> > }
> > )
> [snip]
>
> From the manpage:
>
> "The -S can be used with discipline functions defined in a type to
> indicate
> that the function is static. For a static function, the same method will
> be u
> sed by all instances of that type no matter which instance references it. In
> ad
> dition, it can only use value of variables from the original type definition.
> T
> hese discipline functions cannot be redefined in any type instance."
>
> Or did you mean something else?
>
> --
> Dan Douglas
>
The man page is correct. However, you have to define the function before
you declare it static. Thus,
[snip]
# Static method
function totalpop {
printf 'Total population is currently %d.\n'
"${_.polation}"
}
typeset -fS totalpop
[snip]
should work.
David Korn
[email protected]
_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users