Thanks, even if you replied to the wrong person. =)

Please let me point out that 100% translation is always possible if you don't care about performance.

The most brutal force (if this word exists) is done by emulating the CPU of a processor supporting the language.

I'm not interested to emulate or translate more than 80% of a language even if it might be quite easy with some LISP dialects were most of the complicated constructs are just implemented in some core stuff.

Let me give you an example: there is a very subtle difference how JS and Perl numify strings.

Frankly I don't care to support software which relies on such differences. It even throws warnings.

DB<116> use warnings;0+"2" => 2 DB<117> 0+"ss2" => 0 DB<118> 0+"3ss2" => 3 DB<119> use warnings;0+"3ss2" Argument "3ss2" isn't numeric in addition

>>> a="ss2"; 0+parseInt(a) NaN >>> a="3ss2"; 0+parseInt(a) 3

Of course it's possible to wrap every variable in numeric context with a function which numifies the Perl way.

Such a code would be incredibly slow.

But only supporting the "normal" scalar case were strings are to be treated like numbers is far faster.

Just substract zero:

>>> a="2"; 0+a "02" >>> a="2"; 0+a-0 2

My theory is that it's pretty feasible to create a new language which is a subset of Perl5 or Perl6 and creates acceptable JS.

"Acceptable" doesn't mean 100% compatible. Neither different versions of Perl nor JS are ever 100% compatible.

perlito is already quite good at this.

Cheers Rolf

( addicted to the Perl Programming Language)


In reply to Re^3: sourcefilter with complete parser? by LanX
in thread sourcefilter with complete parser? by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.