[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RFC - GL in scheme (long, with code)
> > An alternative implementation would have the C functions assume their
>> arguments are perfect. Scheme wrappers would check type and count.
>> Is there any advantage or disadvantage to this approach?
>
>I recommend checking in C. For the forseeable future, the cost of
>checking is negligible (i.e., relative to other PLT Scheme overheads)
>--- and since the cost is negligible, there's no reason to skip it.
I'm curious -- why wouldn't one rather have private C-based functions
called things like unsafe:car and provide safe wrapper functions,
implemented in Scheme like this:
(define (car x)
(unless (cons? x) (error 'car ...))
(unsafe:car x))
I would think that the error code is much easier to implement in
Scheme than in C, because a few macro abstractions can really
simplify that checking. In addition, this implementation strategy
means that optimizations can be implemented as Scheme-based code
transformations (probably more relevant for things like `car' than
the ql primitives, tho).
Robby