Skip to content

Commit

Permalink
Add dup and swap macros to prelude
Browse files Browse the repository at this point in the history
  • Loading branch information
Breckin Loggins committed Jan 25, 2012
1 parent d9c7462 commit bdeb2fb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
6 changes: 3 additions & 3 deletions TODO.txt
@@ -1,11 +1,11 @@
NEXT ACTIONS:
- Create dup and swap macros

TYPE SYSTEM:
- Add type macro: pops a symbol and returns the type bound to that symbol
- Add overloaded method for all types that pop up to n-args off the stack and create a new value of that type (in other words, a data constructor for each type)
- Add create-op: pops a type and a bunch of args (as needed by the type), and instantiates a new value for that type, pushing it on the stack, using that type's
data constructor


TYPE SYSTEM:
- Remove createmacro-op and replace with the above infrastructure
- Define createmacro as the first macro
- Create ProductType (takes one or more other types and represents a tuple of those types)
Expand Down
29 changes: 24 additions & 5 deletions prelude/bootstrap.sugar
Expand Up @@ -35,12 +35,31 @@ one or more contiguous non whitespace characters. The environment already has s
symbols bound to opcodes, types, and readers, so we now have enough syntax to execute
commands and create macros.
-

- dup: duplicates the top item on the stack -
`!pushdictionary
`tmp `!set
`tmp `!get
`tmp `!get
`!popdictionary
!createmacro
dup
!set

- swap: reverses the order of the top two items on the stack -
`!pushdictionary
`tmp1 `!set
`tmp2 `!set
`tmp1 `!get
`tmp2 `!get
`!popdictionary
!createmacro
swap
!set

- The reader macro. Invokes a reader by the given name -
`symbol
`!reader
`!read - Invoke the symbol reader -
`!reader
`!read - Invoke the reader by the given symbol -
`symbol `!reader `!read - Invoke the symbol reader -
`!reader `!read - Invoke the reader by the given symbol -
!createmacro - Create the macro with the quoted stack contents -
#
!set - Set the macro binding to the # character -
Expand Down

0 comments on commit bdeb2fb

Please sign in to comment.