Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
codegen: when emitting C-code of the form: ((fn (foo . rest) (body foo rest)) arg1 arg2) code-generate will now treat the argument list as (foo rest) codegen: variadic functions will put extra arguments into a list; their arguments are treated as proper, i.e. (foo . rest) arglists are converted to (foo rest), and variadic functions will put the extra arguments into a list in rest codegen: added variadic handling in C code codegen: added a num_args variable which specifies the number of parameters passed (this information might actually be determined by measuring sp - stack) codegen: 'source and 'code-walk now properly handles variadic arglists utils: added 'properify function to convert improper lists and non-lists into proper lists xe: modified 'fn to handle improper lists for argument lists
- Loading branch information
Showing
4 changed files
with
87 additions
and
14 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
(set list | ||
(fn rest | ||
rest)) | ||
|
||
(prn (list 1 2 3)) ; (1 . (2 . (3 . nil))) | ||
(prn (list 'x 'y)) ; (x . (y . nil)) | ||
(prn (list)) ; nil | ||
|
||
(set test1 | ||
(fn (v . rest) | ||
(pr 'v) (prn v) | ||
(pr 'rest) (prn rest))) | ||
|
||
; v1 | ||
; restnil | ||
(test1 1) | ||
; vx | ||
; rest(y . nil) | ||
(test1 'x 'y) | ||
|
||
(set test2 | ||
(fn (x y . rest) | ||
(pr 'x) (prn x) | ||
(pr 'y) (prn y) | ||
(pr 'rest) (prn rest))) | ||
|
||
; x1 | ||
; y2 | ||
; rest(3 . nil) | ||
(test2 1 2 3) |
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