[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Re: A few questions

From: Graham Fawcett
Subject: Re: [Chicken-users] Re: A few questions
Date: Thu, 31 Jan 2008 21:37:51 -0500

On Jan 31, 2008 8:51 PM, Elf <address@hidden> wrote:
On Thu, 31 Jan 2008, John Cowan wrote:

> Elf scripsit:
>>> (define (foo . rest) (if (= 1 (random 1)) (car rest) #f)
>> in this case, 0.  this entire _expression_ should have been removed by the
>> compiler and replaced by #f, though.
> Okay, make it (random 2) then, smartass.

sure, min 0, max 1. 

I may have lost track of the point of this thread, but I think it's still about providing a reflection mechanism in Chicken to describe the arity of a procedure. If not, then please steer me out of the woods and back on to the main road, because I've lost my way in the dark...

John's halting-problem analogy is precisely correct. You cannot write an algorithm to determine the arity of an arbitrary Scheme procedure. The (random N) is an intentionally simplistic example, but it clearly proves that in some cases a procedure's arity is dependent upon runtime evaluation: its arity is not statically determinable, period.

however, youre forgetting to check that the element exists
before car'ing.  i may be under a mistaken impression, but when working with
rest lists, i thought that one should always check size before trying to grab
elements.  such restrictions are part of why i say its easy... if one
omits this, its a bit harder, but will also crash in other ways from incorrect

I think you're trying to base a general solution upon a prescription: "if only we all did proper bounds checks, we might be able to determine arity". Scheme semantics don't require the bounds check, so how could a sane Scheme reflection mechanism depend upon one?

If the whole point of this thread is that "some people would like better documentation of procedure signatures" then let's build a proper documentation mechanism. Pretending that our language is some language Foo, for some Foo where we can write a proper arity-checking algorithm, is a waste of time.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]