Re: [Chicken-users] Runtime arity?

2008-01-31 Thread Kon Lovett


On Jan 31, 2008, at 5:48 AM, felix winkelmann wrote:


On Jan 29, 2008 6:25 PM, Kon Lovett <[EMAIL PROTECTED]> wrote:


Yeah, it seems we need a database of the built-in's "procedure-
information". Oh well, one more todo.



Is it really necessary to allow accessing the lambda-lists of  
primitives?

The lambda info object is a string - parsing it all the time to figure
out calling conventions is ugly at best and incomplete as well, since
optional and keyword arguments are not visible (only that optional
or rest arguments are at all available). Lambda-info is just a  
debugging
aid, not a reflection mechanism. In the interest of keeping code  
and heap

sizes small I recommend not extending this stuff.


Forgot that lambda-info is a string.

Having accurate arity would be nice for more sophisticated parameter  
checking. When taking procedure params verifying the correct param  
count is an extra level of warm-fuzzy. It keeps the error detection  
local, rather than somewhen & somewhere else in the computation, far  
removed from the error site.


I would leave accurate "lambda info" as a TRAC ticket. As you state,  
even for user lambdas, the DSSSL info isn't saved.


Leaves open the possibility of a "lambda creation hook" that can be  
used by some extension to do all sorts of wonderful things.





cheers,
felix


Best Wishes,
Kon




___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Runtime arity?

2008-01-31 Thread felix winkelmann
On Jan 29, 2008 6:25 PM, Kon Lovett <[EMAIL PROTECTED]> wrote:
>
> Yeah, it seems we need a database of the built-in's "procedure-
> information". Oh well, one more todo.
>

Is it really necessary to allow accessing the lambda-lists of primitives?
The lambda info object is a string - parsing it all the time to figure
out calling conventions is ugly at best and incomplete as well, since
optional and keyword arguments are not visible (only that optional
or rest arguments are at all available). Lambda-info is just a debugging
aid, not a reflection mechanism. In the interest of keeping code and heap
sizes small I recommend not extending this stuff.


cheers,
felix


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Runtime arity?

2008-01-29 Thread Mark Fredrickson
Thanks for the info, Kon.

I've created a ticket to track this:
http://trac.callcc.org/ticket/417

For now, I'll just special case for my needs.

Cheers,
-M

On Jan 29, 2008 12:52 PM, Kon Lovett <[EMAIL PROTECTED]> wrote:
>
> On Jan 29, 2008, at 10:37 AM, John Cowan wrote:
>
> > Graham Fawcett scripsit:
> >
> >> Hm, is it just primitive C functions that need better "procedure
> >> information"? It might be easier to fix that, than to build and
> >> maintain a database.
> >
> > Really only the primitives that are also user-exposed, like +
> > but unlike cons (which is not, technically, a primitive in Chicken).
>
> Yes. By "database" I meant something that maps ##core#primitive
> procedures to "full" lambda info. Don't think it practical to change
> every use of '(##core#primitive "C_foo")' when a central lookup table
> can be built.
>
> >
> > --
> > Samuel Johnson on playing the violin:   John Cowan
> > "Difficult do you call it, Sir? [EMAIL PROTECTED]
> >  I wish it were impossible."http://www.ccil.org/
> > ~cowan
>
> Best Wishes,
> Kon
>
>
>
>
>
> ___
> Chicken-users mailing list
> Chicken-users@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/chicken-users
>


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Runtime arity?

2008-01-29 Thread Kon Lovett


On Jan 29, 2008, at 10:37 AM, John Cowan wrote:


Graham Fawcett scripsit:


Hm, is it just primitive C functions that need better "procedure
information"? It might be easier to fix that, than to build and
maintain a database.


Really only the primitives that are also user-exposed, like +
but unlike cons (which is not, technically, a primitive in Chicken).


Yes. By "database" I meant something that maps ##core#primitive  
procedures to "full" lambda info. Don't think it practical to change  
every use of '(##core#primitive "C_foo")' when a central lookup table  
can be built.




--
Samuel Johnson on playing the violin:   John Cowan
"Difficult do you call it, Sir? [EMAIL PROTECTED]
 I wish it were impossible."http://www.ccil.org/ 
~cowan


Best Wishes,
Kon




___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Runtime arity?

2008-01-29 Thread John Cowan
Graham Fawcett scripsit:

> Hm, is it just primitive C functions that need better "procedure
> information"? It might be easier to fix that, than to build and
> maintain a database.

Really only the primitives that are also user-exposed, like +
but unlike cons (which is not, technically, a primitive in Chicken).

-- 
Samuel Johnson on playing the violin:   John Cowan
"Difficult do you call it, Sir? [EMAIL PROTECTED]
 I wish it were impossible."http://www.ccil.org/~cowan


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Runtime arity?

2008-01-29 Thread Graham Fawcett
On Jan 29, 2008 12:25 PM, Kon Lovett <[EMAIL PROTECTED]> wrote:
> On Jan 29, 2008, at 9:18 AM, John Cowan wrote:
> > Graham Fawcett scripsit:
> >
> >> It's of less use when the procedure takes variable arguments, though,
> > Sometimes you get a useful result:
> >
> >   (procedure-information list) => (list . lst120)
> > And sometimes you don't:
> >   (procedure-information +) => C_plus
>
> Yeah, it seems we need a database of the built-in's "procedure-
> information". Oh well, one more todo.

Hm, is it just primitive C functions that need better "procedure
information"? It might be easier to fix that, than to build and
maintain a database.

G


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Runtime arity?

2008-01-29 Thread Kon Lovett


On Jan 29, 2008, at 9:18 AM, John Cowan wrote:


Graham Fawcett scripsit:


It's of less use when the procedure takes variable arguments, though,


Sometimes you get a useful result:

(procedure-information list) => (list . lst120)

And sometimes you don't:

(procedure-information +) => C_plus


Yeah, it seems we need a database of the built-in's "procedure- 
information". Oh well, one more todo.




--
John Cowan  [EMAIL PROTECTED]http://ccil.org/~cowan
No man is an island, entire of itself; every man is a piece of the
continent, a part of the main.  If a clod be washed away by the sea,
Europe is the less, as well as if a promontory were, as well as if a
manor of thy friends or of thine own were: any man's death  
diminishes me,

because I am involved in mankind, and therefore never send to know for
whom the bell tolls; it tolls for thee.  --John Donne


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Best Wishes,
Kon




___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Runtime arity?

2008-01-29 Thread John Cowan
Graham Fawcett scripsit:

> It's of less use when the procedure takes variable arguments, though,

Sometimes you get a useful result:

(procedure-information list) => (list . lst120)

And sometimes you don't:

(procedure-information +) => C_plus

-- 
John Cowan  [EMAIL PROTECTED]http://ccil.org/~cowan
No man is an island, entire of itself; every man is a piece of the
continent, a part of the main.  If a clod be washed away by the sea,
Europe is the less, as well as if a promontory were, as well as if a
manor of thy friends or of thine own were: any man's death diminishes me,
because I am involved in mankind, and therefore never send to know for
whom the bell tolls; it tolls for thee.  --John Donne


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Runtime arity?

2008-01-29 Thread Graham Fawcett
On Jan 29, 2008 11:28 AM, Mark Fredrickson <[EMAIL PROTECTED]> wrote:
> Is it possible to determine at run time the arity of function? I'm
> thinking something like
>
> (arity (lambda (x y z) (* x y z)))
> => 3

You can use 'procedure-information':

(procedure-information (lambda (x y z) (* x y z)))

=> (? x y z)

where (? x y z) is an s-expression that you can parse.
It's of less use when the procedure takes variable arguments, though,
and of course it doesn't tell you whether the procedure returns
multiple values.

Graham


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users