bsansouci / bsansouci/lisp-bot
WIP Proposal for exports
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 7
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
Usage
```
(define namespace1
(module
(define helper (lambda etc 1)
(define fnname1 (lambda etc 2)
(export ("fnname1" fnname1))
(export ("fnname2" (lambda etc 3)))
)
)
```
This would define `namespace1` as being the hashmap
`{"fnname1": (lambda etc 2), "fnname2:(lambda etc 3)"}`.
The idea is that you could create a namespace that is a hashmap of names to functions and then call functions by going `(namespace1 "fnname1")`. If we extended the parser to replace a dot or colon accessor with a hashmap access then we could have `namespace1.fnname1`.
```
(define-macro module
(lambda
(args ...)
(let (internal-export-hm (ref (hashmap))
export (lambda (export-pair) (set! internal-export-hm (assoc (get internal-export-hm) (car export-pair) (second export-pair) ))
(...run all of "args", return (get internal-export-hm))
)
)
)
```
`module` would work by keeping track of an internal ref to a hashmap that is modified every time `export` is called. It is a macro that runs all the commands that it is passed in its own scope so nothing gets defined globally. It then returns what the ref is pointing to, which is then assigned to `namespace1` in the define.
The trickiest bit of this is making it possible to do defines in the scope of `module`.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue provides a usage example and a macro sketch for module and export, but names no files or tests. Start by locating the parser and macro implementation, then determine how scoped defines currently work. Done would mean agreeing on the namespace, export, accessor, and scope behavior and covering it with tests.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100