Skip to content

Conversation

@Frityet
Copy link
Collaborator

@Frityet Frityet commented Oct 16, 2025

This PR implements macro support for Teal.

Project Proposal

hishamhm and others added 30 commits June 24, 2025 16:39
Shrinks teal/precompiled/default_env.lua
from 189928 to 100747 bytes.

Compilation times for `tl check hello.tl`
(where `hello.tl` is `print("hello")`,
i.e. measuring compiler baseline overhead)

* master: 21.1 ms
* original precompiler: 15.9 ms
* revised precompiler: 13.9 ms
It was getting unwieldy. Move the more involved logic
to an `extras/make.sh` Bash script, which I tried to make
as readable as possible.
They are now plain .d.tl files, and in `new_env` (which is
currently the "manual" environment builder), they are loaded using the
standard require_module mechanism, same as the other predefined_modules
(or any other uses of `require` by Teal code, really!)

Of course, `environment.default` now uses the precompiled one.

And yes, this is an experiment in the direction of perhaps someday
providing a precompiled type definition facility for all modules,
aiming to speed up compilations. This has the difficulty that the
Teal environment currently relies on globally unique numeric typeids.
We'd have to switch to a name-based system with a linking step.
(The standard library can get away with this because it is always
the first module on an empty environment, so I can reliably start
my typeid count from 1.)
Also, we can now run the Makefile bootstrapping using
the Teal binary, like so:

```
extras/binary.sh
make STABLE_TL=_binary/build/tl
```
Useful for development.
Frityet added 27 commits July 16, 2025 22:03
Mega commit because I fully messed up my local git and so I had to re-clone and just copy my files over.

Failing tests are mostly with the new comment retention which need to be added later
forgot to include in last commit
```lua
local x = `local $y = "hi"`
```
to
```lua
local x = { kind = "local_declaration", { kind = "identifier", clone(y) } }
```

etc
This was previously done in the luagen phase which was incorrect.
@github-actions
Copy link

Teal Playground URL: https://1040--teal-playground-preview.netlify.app

@Frityet Frityet closed this Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants