-
Notifications
You must be signed in to change notification settings - Fork 6
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
Transpiler? #3
Comments
Probably not, the resulting JavaScript would be pretty horrific though
…On Wed, Jan 1, 2020, 21:42 Aliaksei Chapyzhenka ***@***.***> wrote:
Would it be difficult to emit equivalent JavaScript after parsing TCL?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3?email_source=notifications&email_token=AAZHPTHII6VLSBVC24OGKYTQ3TWZVA5CNFSM4KB4O3H2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IDSYDIA>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZHPTGAUBFN5ZCALBMZ4ODQ3TWZVANCNFSM4KB4O3HQ>
.
|
I understand, that there will be corner cases, but I was thinking about something like this: https://github.com/drom/tcl/blob/master/examples.md |
What you would get would look nothing like that, and couldn't - since Tcl
requires that some things block and JavaScript forbids it. So the execution
engine used in Tcl.js used a continuation passing trampoline approach. The
result would be as alien to read in JavaScript as the machine code is that
is generated by a modern compiler from c is.
It would be possible to "translate" some toy subset of Tcl to meaningful
JavaScript code, but only by giving up any pretense of actually being
proper Tcl. The approach used by some of the JavaScript implementations of
Tcl of converting Tcl expressions to equivalent JavaScript ones runs into
many incompatible behaviors for instance. Think about exceptions, numeric
range considerations, the fact that JavaScript doesn't actually have
integers, Tclish coercion of certain strings to Boolean values, and many
others.
…On Fri, Jan 3, 2020, 03:26 Aliaksei Chapyzhenka ***@***.***> wrote:
I understand, that there will be corner cases, but I was thinking about
something like this: https://github.com/drom/tcl/blob/master/examples.md
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3?email_source=notifications&email_token=AAZHPTB4SLKT6RAYHLSRWCTQ32H4FA5CNFSM4KB4O3H2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIAAUZI#issuecomment-570428005>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZHPTCMKGFLIAINMTAEEU3Q32H4FANCNFSM4KB4O3HQ>
.
|
Could elaborate on it? Give some example?
Generated JavaScript does not need to be too pretty from the start. We can work later to prettify some safe cases.
The code needs to behave as proper TCL.
For numbers, JS has no problem with INT32, UINT32, F64, F32 if properly annotated. http://asmjs.org/spec/latest/#annotations For exceptions. We can construct source map from TCL to JS, catch JS exception and report it in TCL style. For coercion, what if we replace TCL operators with JS function calls? |
You'll need to work through the way the execution engine works to understand why this is a bad fit. You could just use the parser and then attempt to transpile some subset of the language, but working with the output of the parser is a bit nasty (it's optimised for speed rather ease of use). Take a look at demos/parser.html for an example of how to interact with the parser, and to view a marked-up version of the parser output for a given script. |
what would be the point of transpiling? The implementation offers a number procs that depend down on tcl and js code... see registered(). Then the transpiled code shims the functions back and forth and like he said it's a mess. There is no upside. However, if your issue is speed... maybe testing with webassembly. This is a great project idea. I have been working on something similar with golang and Picol. |
Would it be difficult to emit equivalent JavaScript after parsing TCL?
The text was updated successfully, but these errors were encountered: