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

F# Own Source-generation/Meta-programming #1396

Closed
Xyncgas opened this issue Dec 14, 2024 · 5 comments
Closed

F# Own Source-generation/Meta-programming #1396

Xyncgas opened this issue Dec 14, 2024 · 5 comments

Comments

@Xyncgas
Copy link

Xyncgas commented Dec 14, 2024

#864 was for .NET source generator

Current issue is for having fsharp's own source generator / Meta programming

I was writing C++ template then I felt like I was writing codes really useful but hard for people to see so I was interested doing such a thing in F# because I use it too, I imagined having the meta programming in F# would be useful, because C# already has source generator and F# types inferencing already saving a lot of works typing, it would be a nice addition having a feature that does more in this field

It would be allowing me :

Write expression first, generate type later :

    //I can be calling it without defining MyConstructor or a type that has it, instead there is a template that handles arguments of "string" and "int" and maybe others, and during compilation a constructor that supports these types is generated or error messages are provided if the scenario is unsupported
    MyConstructor("string", 1)

People can now use expression freely expecting it would be correct and has support to types involved in the expression, the source-generating / meta-programming aspect of the F# language would ensure you can use the expression, and compilation generates specific type so the alternative way of boxing aguments to object and handling each types when the program is running is not needed (saving computation)

@vzarytovskii
Copy link

F# has Myriad, which is community driven library. There are no other plans to have anything out of the box at this point.

@vzarytovskii vzarytovskii closed this as not planned Won't fix, can't repro, duplicate, stale Dec 14, 2024
@Xyncgas
Copy link
Author

Xyncgas commented Dec 15, 2024

OK, adding to the words I said : F# should be making functions and expressions first citizens, people should not write classes or define types to deal with the object oriented aspect and should write types for classification needs. Imagine that's a reality we enjoy.

@jwosty
Copy link
Contributor

jwosty commented Dec 15, 2024

What you're taking about sounds kind of like LISP macros. While that would be really neat, I think that type providers were intended to be the mechanism for metaprogramming instead. Perhaps you could channel your suggestion into improving type providers? See for example the approved-in-principal suggestion about accepting types as inputs to type providers (which would allow for solving some of the same kinds of problems that macros solve)

@T-Gro
Copy link
Contributor

T-Gro commented Dec 16, 2024

Agree, types as inputs to TPs would address a lot of the concerns (the second half would I guess best correspond to quotations (= expressions) as inputs, but I do not want to open that box)

@jwosty
Copy link
Contributor

jwosty commented Dec 16, 2024

For what it's worth here's the specific language suggestion / RFC we're referring to: #212

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

No branches or pull requests

4 participants