Re: Re: Need usable fparam_ function attribute

Lenard Lindstrom <[email protected]>
Newsgroups gmane.comp.lang.prothon.user
Message-ID <Mahogany-0.66.0-4294595635-20040702-163228.00@pop3.norton.antivirus>
On Fri, 25 Jun 2004 18:17:59 -0700 Mark Hahn <[email protected]> wrote:

> Lenard Lindstrom wrote:
> 
> > Now that import works for prothon modules more serious projects
> > can be started. The document tools needs a solid introspection
> > module. One critical piece of information is the parameter
> > specifications of a function. Functions with parameters have
> > a fparams_ attribute. But it is unusable from within prothon.
> >
> > Prothon 0.1 Interactive Console, Build 566, Jun  3 2004 (Ctrl-D to
> > exit)
> >>>> def foo(x, y=9, *a, **k): pass
> >>>> foo.fparams_
> > [`x, <NULL>, `y, 9, <objptr:1>, `a, <objptr:2>, `k]
> >>>>
> >
> > Attempting to use foo.fparams_[1] raises a missing object exception.
> > Attempting to retrieve foo.fparams_[4] causes a page fault.
> 
> This has been fixed in a recent release.
> 
> > I gather
> > the current fparams_ is an interim solution. What will the final
> > format be?
> 
> Try it and see.  It is pretty much as final as anything else is in Prothon.
> 
> > Will all functions have an fparam_, even those without
> > parameters?
> 
> Hmm, I don't remember.  Try it and see.
> 
This is a good start. I have a working inspect.getparspec() function now. But the
default argument values come across as featureless:

Prothon 0.1 Interactive Console, Build 660, Jun 24 2004 (Ctrl-D to exit)
O>> import inspect
O>> def foo(x, y=1, z=2, *a, **k): pass
O>> print(inspect.getparspec(foo))
[[$x, $y, $z], $a, $k, [<Object:8ef5a0>, <Object:8ef5c0>]]
O>>

Object <Object:8ef5a0> should be "1". But default values in fparams_ have no
attributes and I cannot get at the values they represent. Is this a result
of evaluation of default values for each function call? Is there any way to
make the values available for constant defaults?

Lenard Lindstrom
<[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.