You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to have a frontend for sourir as a usecase. I see several possible levels:
Syntactic Sugar
The language could be just syntactic sugar on top of sourir.
i = read()
sum = 0
for j in 0 to i:
sum += i
Dynamic Types
The language could have dynamic types.
if (read() == 0)
i = "foo"
else
i = 2
print i + i
In sourir the primitive operations like '+' only work on one primitive type (eg. + only on integers). Lets assume we want a programming language L where primops are generic. For example you can write 2+2 as well as "foo"+"foo". And lets assume we want it to be dynamically typed and not type-inferred (ie. like in the example above at compile time it is not yet clear if the integer+ or the string+ is required).
For a compiler from L to sourir the idea is to keep type tags. This means that every value is stored along information about its type. For example i = 2 creates a heap cell with the content <int, 2>. To support the generic + a dispatch table is needed. For example something like if a.1 == int && b.i == int then res = <int, a.2 (integer+) b.2>
To support such a language sourir needs to be extended a bit. Either with tuples (like in the example above) or (simpler) a type-testing primop.
Functions
If the source language should have functions (which would be very nice) then we'll need to extend sourir a bit. Though maybe not that much. Using segments + some cps encoding it should be possible to simulate functions.
The text was updated successfully, but these errors were encountered:
o-
changed the title
Frontend
[Project] Frontend
Feb 9, 2017
It would be nice to have a frontend for sourir as a usecase. I see several possible levels:
Syntactic Sugar
The language could be just syntactic sugar on top of sourir.
Dynamic Types
The language could have dynamic types.
In sourir the primitive operations like '+' only work on one primitive type (eg. + only on integers). Lets assume we want a programming language L where primops are generic. For example you can write
2+2
as well as"foo"+"foo"
. And lets assume we want it to be dynamically typed and not type-inferred (ie. like in the example above at compile time it is not yet clear if the integer+ or the string+ is required).For a compiler from L to sourir the idea is to keep type tags. This means that every value is stored along information about its type. For example
i = 2
creates a heap cell with the content<int, 2>
. To support the generic + a dispatch table is needed. For example something likeif a.1 == int && b.i == int then res = <int, a.2 (integer+) b.2>
To support such a language sourir needs to be extended a bit. Either with tuples (like in the example above) or (simpler) a type-testing primop.
Functions
If the source language should have functions (which would be very nice) then we'll need to extend sourir a bit. Though maybe not that much. Using segments + some cps encoding it should be possible to simulate functions.
The text was updated successfully, but these errors were encountered: