#2 Expose more of the internal

closed
nobody
None
5
2007-05-14
2006-11-20
Tom Breton
No

Toward the goal of making Tinyscheme more suitable for
Scheme->C->Scheme calling, please expose more of the
internal functionality.

Specifically:

Functionality to read the values of Scheme symbols
from C callbacks. Being able to simply eval symbols
from C makes life much easier. One suggestion: expose
find_slot_in_env and slot_value_in_env. Another
suggestion: Provide this thru an entry point suitable
for nested calling (as requested in another feature
request)

list_length. It's very common to want to know how
long a list a C callback was given. One important use
is the defensive programming technique of rejecting
wrong-length argument lists. IMO this is so central
that it should not require re-entering Scheme or
"rolling your own" via is_pair and pair_cdr.

And while they are much less crucial and I stop short
of requesting this, I see no downside to exposing
mk_empty_string, append, reverse, and eqv.

Discussion

  • Tom Breton
    Tom Breton
    2007-05-13

    Logged In: YES
    user_id=62720
    Originator: YES

    On implementing this: Exposing list_length is straightforward.

    On inspection, I don't think that either slot function should be exposed. If a non-environment was passed as the environment arg, they'd make a mess.

    scheme_apply0 and scheme_call don't return values, but otherwise they appear suitable. I propose to change their signatures to return "pointer" and add the semantics that they return the value of the expression or application, respectively.

    For reverse and append, the list-ness of the argument is not checked, so they are not safe to expose. eqv and mk_empty_string seem unproblematic to expose.

     
  • Tom Breton
    Tom Breton
    2007-05-13

    Logged In: YES
    user_id=62720
    Originator: YES

    reverse and append do implicitly check for list-ness and safely handle each possibility. My mistake; I knew that back when I posted the request.

     
  • Tom Breton
    Tom Breton
    2007-05-14

    Logged In: YES
    user_id=62720
    Originator: YES

    File Added: test-apply1.c

     
  • Tom Breton
    Tom Breton
    2007-05-14

    Satisfaction test for scheme_eval returning value (C code)

     
    Attachments
  • Tom Breton
    Tom Breton
    2007-05-14

    • status: open --> closed
     
  • Tom Breton
    Tom Breton
    2007-05-14

    Logged In: YES
    user_id=62720
    Originator: YES

    Provided as "scheme_eval", a more general version of "scheme_apply1".