Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bikeshedding: MLang language fragment syntax #199

Open
johnwikman opened this issue Oct 9, 2020 · 0 comments
Open

Bikeshedding: MLang language fragment syntax #199

johnwikman opened this issue Oct 9, 2020 · 0 comments
Labels
discussion An issue that warrants discussion

Comments

@johnwikman
Copy link
Contributor

There have been a couple discussions recently about what the keyword for MLang language fragments should be, without reaching a resounding consensus. Mainly regarding whether we should use the keyword frag, or stick with the keyword lang. There are motivations for both due to how the syntax looks:

-- We are language fragments, not intended to be used on our own... but we are
-- still denoted by lang!
lang LittleFoo
  syn Expr =
  | XFoo Int

  sem handle =
  | XFoo i -> XFoo (addi i 1)
end

lang LittleBar
  syn Expr =
  | XBar Bool

  sem handle =
  | XBar b -> XBar (not b)
end



-- I am a language intended to be used directly in the code!
lang FooBar = LittleFoo + LittleBar



-- I am a language intended to be used directly in the code as well, but I am
-- also partially defined in the same way as LittleFoo and LittleBar...
lang TreeFooBar = LittleFoo + LittleBar
  syn Expr =
  | XBranch (Expr, Expr)

  sem handle =
  | XBranch (l, r) = XBranch (handle l, handle r)
end



mexpr
let fb =
  use FooBar in
  ...
in

let tfb =
  use TreeFooBar in
  ...
in

As there are motivations for both, it might also be the case that neither frag or lang is the right keyword to use. Maybe something like module could be another option, also replacing syn, sem by con, match respectively.

Hopefully I have managed to capture the key motivations brought forth in recent discussions.

@david-broman david-broman added the discussion An issue that warrants discussion label Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion An issue that warrants discussion
Projects
None yet
Development

No branches or pull requests

2 participants