Skip to content

Commit

Permalink
Simplify README a little. #11
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenhombre committed Jul 26, 2022
1 parent cbaad75 commit ac0b52d
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,27 +131,11 @@ For function names which are valid in Scheme but not in Python (such
as `+`), you'll need to use `register_fn` rather than `scheme_fn`.

At the current time, any builtin function (but not special forms) can
be overridden using this mechanism:

def strange_plus(args):
# addition!
if all(typeof(arg) in ['float', 'int']
for arg in args):
return int_(sum(value(arg) for arg in args))
# concatenation!
elif all(typeof(arg) == 'list' for arg in args):
ret = []
for arg in args:
ret += value(arg)
return list_(ret)
# uhhhh... everything else!
else:
return atom("aStrangerThing")

# warning! Change to built-in function:
register_fn('+', strange_plus)

Once your Python functions have been registered, your code should then
be overridden using this mechanism. There's [an example of
this](https://github.com/eigenhombre/smallscheme/blob/master/smallscheme/test_interop.py#L22)
in the tests.

Once your Python functions have been registered, your code can then
execute Scheme expressions, either by executing one or more Scheme
source files, or by launching a REPL for the user:

Expand Down

0 comments on commit ac0b52d

Please sign in to comment.