Marcelle Rusu (they/them)
08/28/2023, 2:04 PM# here's a sample program in my (object oriented) language
fn add(a, b) = a + b
add(1, 2)
generated logic program in pseudo syntax (#A
is a pattern to check value is type of A
, ?a
is like prolog's A
, {...}
is map literal.)
-- preloaded facts
lookup(#Number, :+, {args: [#Number, #Number], ret: #Number}).
-- program
add(?a, ?b, ?ret) :- lookup(?a, :+, {args: [?a, ?b], ret: ?ret}).
?- add(1, 2, ?_).
The specifics of my logic language is likely flawed, but I'm curious about the general idea of using a fully-fledged logic language to generate a program in & run instead of generated a typed AST and running ad-hoc type systems.
My question is, what are people's thoughts on this? Any previous work in this area? Any obvious flaws?guitarvydas
08/28/2023, 2:57 PMMarcelle Rusu (they/them)
08/28/2023, 3:17 PMJustin Blank
08/28/2023, 4:13 PMKonrad Hinsen
08/28/2023, 6:51 PMMarcelle Rusu (they/them)
08/28/2023, 7:11 PMI somewhat suspect that the traditional tight integration of type systems and languages comes from the benefit that type checking brings to optimization.There's no reason why the database generated from the logic language can't stick around to be queried for optimizations, right? One thing that I imagine will require some work is interpreting errors (no answers found) for the results of running these programs. I'm imagining when this logic program runs it'll have to keep track of which queries / predicates succeeded & which didn't - and something to make something like a stacktrace, maybe even track that in a logic db that can also be queried to emit domain specific (nice) error messages. I think the big idea is having a database that contains really detailed statically analyzed facts which can be used to check correctness, do optimizations, or even help with automated refactoring tools. So it might not even need to be 1 logic language, but a shared database system which all the logic languages can speak & store facts & query from.
Konrad Hinsen
08/29/2023, 5:22 AMThere's no reason why the database generated from the logic language can't stick around to be queried for optimizations, right?Technically, no. Socially, it means that the generation of important information is no longer under control of the compiler writer, and even language designer. They would have to cooperate with the users of their language and tool, and negotiate protocols for information exchange. It's more convenient to be a dictator.
wtaysom
08/29/2023, 7:02 AMKartik Agaram
Konrad Hinsen
08/30/2023, 9:02 AMMarcelle Rusu (they/them)
08/30/2023, 2:03 PMKonrad Hinsen
08/30/2023, 6:54 PMwtaysom
09/01/2023, 4:23 AMKartik Agaram
wtaysom
09/04/2023, 5:07 PMKonrad Hinsen
09/05/2023, 3:51 AM