This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro pseudop (method . args) | |
(let ((as-name (symbol (+ "emit_" (str method)))) | |
(method (symbol (+ "__compiler__.pseudop_" (str method))))) | |
(if args | |
`(defmacro ,as-name ,args | |
(cons ',method ,@args nil)) | |
`(defmacro ,as-name () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maybe:python-sibilant siege$ sibilant sample_defclass.lspy | |
Tom says: Hey there, Sally | |
Sally says: What's up, Tom | |
Tom says: Good-bye! | |
Sally says: Good-bye! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maybe:python-sibilant siege$ python3 sample1.py | |
Traceback (most recent call last): | |
File "sample1.py", line 18, in <module> | |
call_a(100) | |
File "sample1.py", line 7, in call_a | |
call_1(call_b, value) | |
File "sample2.lspy", line 3, in call_1 | |
(into arg)) | |
File "sample1.py", line 11, in call_b | |
call_2(call_c, value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maybe:python-sibilant siege$ sibilant sample.lspy | |
True is True | |
False is False | |
None is False | |
nil is False | |
True is True | |
100 is True | |
False is False | |
-100 is True | |
(1 will you 8 flake tacos_1 tacos_2 tacos_3 tacos_4 tacos_5 tacos_2 tacos_3 tacos_4 tacos_5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maybe:python-sibilant siege$ cat tacos.lspy | |
(defun make_tacos (X) | |
(cons 'tacos X)) | |
(define tacos 'awesome) | |
maybe:python-sibilant siege$ python3 | |
Python 3.5.3 (default, Apr 23 2017, 18:09:27) | |
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
My take on the Church of Lambda. I've tweaked and added a few thing to | |
make life more enjoyable | |
author: Christopher O'Brien <siege@preoccupied.net> | |
inspiration from http://doos.m3r.nl/~ivo/lambda.txt | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maybe:python-spexy siege$ PYTHONPATH=./ python tmp/spexy_try.py | |
The original spexy source is | |
----- | |
(defun division (x y) | |
(let ((result None)) | |
(try | |
(setf result (/ x y)) | |
((ZeroDivisionError) | |
(println "division by zero!" x "/" y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maybe:python-spexy siege$ PYTHONPATH=./ python | |
Python 2.7.6 (default, Nov 18 2013, 15:12:51) | |
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> from spexy import repl | |
>>> from datetime import datetime | |
>>> repl(globals()) | |
>>>> (let ((who "siege") (date 1999)) | |
(letrec ((fmt "Hello %s, party like it is %i!") | |
(msg (% fmt (make-tuple who date)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[siege@maybe src]$ python spexy.py | |
>>>> (defun make_pair () | |
(letrec ((value None) | |
(getter (lambda () value)) | |
(setter (lambda (v) (setf value v)))) | |
(make-list getter setter))) | |
--> globals().__setitem__('make_pair', (lambda : ((lambda value, getter, setter: ((value.__setitem__(0, None), getter.__setitem__(0, (lambda : value[0])), setter.__setitem__(0, (lambda v: value.__setitem__(0, v))),)[-1], [getter[0], setter[0],],)[-1])([None], [None], [None])))) | |
>>>> (letrec ((gs (make_pair))) | |
(define getter (getf gs 0)) | |
(define setter (getf gs 1))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
""" | |
Given two tags, do absolutely nothing. | |
This script is just a stub illustrating the bits I re-use for every | |
CLI utility I write. |