In article <
8073bde7-cfb6-4c5f...@googlegroups.com>,
Digi <
cosm...@gmail.com> wrote:
>Hi!
>
>is that possible to extend typeof() functionality like this way:
>
>func f(a) {
> print typeof(a) }
>
>BEGIN{ f() }
>
>output:
>
>unpresent
>
>
>the feature is in that typeof() performed from the function body return
>"unpresent" in case if parameter is not present in function call f()
>
>currently gawk returns for the parameters that is not present in function
>call - "untyped" - that is not totally clear to understand is parameter
>present or not.
Comments:
1) The obvious "Well, yes, it might be nice, but it's not there, so all
we can do is offer workarounds" comment...
2) I tested your code, and the only way I could make an issue of it is
by calling f(z) - where z is an otherwise unused variable. Then
you get "untyped" even though you did pass something in the call.
Which then begs the question: Do you really need to be able to
distinguish those two cases - being called with no parameter vs.
being called with an undefined parameter?
3) It sounds like what you're really looking for is TAWK's argcount()
and argval() functions. I've written about these TAWK features
before in this newsgroup, so will not re-iterate here. Yes, it
would be nice if GAWK had these features. And, no doubt, someday,
it will.
>i believe that there is no needs to explain the reason of such kind feature
Actually, it would be nice/helpful to see your use case. Thanks.
--
"They say if you play a Microsoft CD backwards, you hear satanic messages.
Thats nothing, cause if you play it forwards, it installs Windows."