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

Support lazy keyword #23

Open
RobertHarper opened this issue Mar 20, 2023 · 5 comments
Open

Support lazy keyword #23

RobertHarper opened this issue Mar 20, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@RobertHarper
Copy link

Problem

SML/NJ supports laziness via the Control.lazysml boolean reference, which if set to true enables "lazy" as a keyword on datatype declarations and on val [rec] declarations.

eg, datatype lazy stream = Cons of int * stream
eg, val rec lazy zeros = Cons (0, zeros)

Solution

It would be great to have a way to enable highlighting of the keyword "lazy" as with the other constructs of the language.

@RobertHarper RobertHarper added the enhancement New feature or request label Mar 20, 2023
@azdavis
Copy link
Owner

azdavis commented Mar 20, 2023

Shouldn't be too hard to parse/syntax highlight this keyword. I'm interested, though, how it affects the static semantics. Is there a formalization written up that i may consult to know how it affects typechecking?

@azdavis
Copy link
Owner

azdavis commented Mar 21, 2023

There's also some compatibility considerations - if this 'laziness' feature is not enabled, then val lazy = 3 should not syntax error. In other words, lazy should only sometimes be a keyword.

@RobertHarper
Copy link
Author

Yes, it should be an optional feature, the question is how to indicate that it's "on"? In SML/NJ it's a matter of an assignment to a variable.

As to the statics the paper by MacQueen and Taha (and possibly another) does it: https://www.diva-portal.org/smash/get/diva2:413532/FULLTEXT01.pdf.

@RobertHarper
Copy link
Author

@azdavis
Copy link
Owner

azdavis commented Mar 24, 2023

re: indicating it’s on: i was thinking a config option in millet.toml.

as for implementing this feature, it looks like you can translate down the “lazy” language into the regular language with some local transformations.

the only probably i foresee in millet is that millet does not currently have the ability to transform the code as it is typechecking.

i think we’d need the ability to do that, or at least, we’d need to have scoping/name resolution information, because we need to track which data types and vals are lazy in order to transform their usage sites. but name resolution requires the rest of typechecking in sml because of the module system.

@azdavis azdavis changed the title lazy keyword Support lazy keyword Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants