Skip to content

Experimental macro require v2 - #1102

Draft
Frityet wants to merge 8 commits into
teal-language:mainfrom
Frityet:macmods
Draft

Experimental macro require v2#1102
Frityet wants to merge 8 commits into
teal-language:mainfrom
Frityet:macmods

Conversation

@Frityet

@Frityet Frityet commented Mar 12, 2026

Copy link
Copy Markdown
Collaborator

An update to #1096 with new semantics:

-- macros.tl
local record macros end
macro macros.double!(x: Statement)
   return ```
      $x
      $x
   ```
end

return macros
-- main.tl
local m = require("macros")
-- also supported: local type m = require("macros")
m.double!(print("hi"))

@Frityet

Frityet commented Mar 12, 2026

Copy link
Copy Markdown
Collaborator Author

@hishamhm I can also make it into local macro ... = require(...)

@github-actions

Copy link
Copy Markdown

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

@hishamhm

Copy link
Copy Markdown
Member

@hishamhm I can also make it into local macro ... = require(...)

If you don't do that, how do you disambiguate which type of require it is?

Frityet added 3 commits March 23, 2026 18:23
# Conflicts:
#	teal/macro_eval.lua
#	teal/macro_eval.tl
#	teal/reader.lua
#	teal/reader.tl
@mtdowling

Copy link
Copy Markdown
Contributor

I would love exported macros in the next version of Teal. Let me know if there's anything I can do to help.

@Frityet

Frityet commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator Author

I would love exported macros in the next version of Teal. Let me know if there's anything I can do to help.

It all works pretty great right now (I think this PR doesn't have attaching macros to records in it, but that's fixed in my tl-ng branch) it's just a matter of agreeing on design. I tried tp make it model off of macroexps, where macroexps can be attached to records and interfaces

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.

3 participants