Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/soegaard/super
Adds syntax to racket languages
https://github.com/soegaard/super
racket syntax
Last synced: 25 days ago
JSON representation
Adds syntax to racket languages
- Host: GitHub
- URL: https://github.com/soegaard/super
- Owner: soegaard
- License: mit
- Created: 2022-08-02T22:04:25.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-17T09:43:43.000Z (over 2 years ago)
- Last Synced: 2024-11-11T14:55:46.656Z (3 months ago)
- Topics: racket, syntax
- Language: Racket
- Homepage:
- Size: 19.5 KB
- Stars: 11
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# super
## Introduction
The `super` language is a meta-language that adds features
to an existing racket language.Use it as:
#lang super
where is the name of an language like racket, racket or similar.
## Field and Method Access, Method Calls
In a super language identifiers with dots can be used for field access
and for method calls.1. o.f access field f of object o
2. o.f1.f2 access field f2 of object o.f1
3. (o .m a ...) invoke method m on object o wth arguments a...
4. (o .m1 a1 ... .m2 a2 ...) same as ((o .m1 a1 ...) .m2 a2 ...)
5. (o.m a ...) invoke method m on object o wth arguments a...
6. (o.m a ... .m1 a1 ...) invoke method m1 on resultof object (o.m a ...) with arguments a2 ...See `test-object-notation.rkt` for an example.
## Indexing with square brackets
In a super language the reader reads an expressions of the form
id[expr ...] (no space between the identifier and the bracket)
as
(#%ref id expr ...).
A default binding for `#%ref` is provide that allows indexing for
vectors, lists, strings and bytes.The default bindings is defined like this:
(define-syntax (#%ref stx)
(syntax-parse stx
[(#%ref x:id index:expr)
(syntax/loc stx
(let ([i index])
(cond
[(vector? x) (vector-ref x i)]
[(list? x) (list-ref x i)]
[(string? x) (string-ref x i)]
[(bytes? x) (bytes-ref x i)]
[else
(error '#%ref (~a "expected a vector, list, string or byte string, got: " x))])))]))See `test-ref-expressions.rkt` for an example.