[prev in list] [next in list] [prev in thread] [next in thread]
List: ast-users
Subject: Re: [ast-users] No static functions in typeset -T xxx=(...) ... / was: Re: _ doesn't refer to the co
From: David Korn <dgk () research ! att ! com>
Date: 2013-08-12 15:42:41
Message-ID: 201308121542.r7CFgfmo025058 () terra ! research ! att ! com
[Download RAW message or body]
cc: ast-users@lists.research.att.com
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
dgk@research.att.com
_______________________________________________
ast-users mailing list
ast-users@lists.research.att.com
http://lists.research.att.com/mailman/listinfo/ast-users
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic