does streamline support the "let" statement/expression?

12 views
Skip to first unread message

a.r...@gmx.de

unread,
Apr 2, 2014, 9:56:55 AM4/2/14
to stream...@googlegroups.com
Hello!

I've just started experimenting with "streamline.js" and immediately ran into a problem: I can't convince "streamline.js" to accept "let <varname> = <value>".

Does "streamline.js" support block-local variables?

Thanks in advance for any answer!

Kind regards,

Andreas Rozek

a.r...@gmx.de

unread,
Apr 2, 2014, 10:02:03 AM4/2/14
to stream...@googlegroups.com
Do become more precise:

I'm using the "interactive demo" (great idea!)

My "source code" (on the left side) is:

<code>
// Natural iterative version

function hugo (_) {
  let Result = 1;
  return Result;
};

demo('Result = ' + hugo(_), _);
</code>

and it get's translated into (on the right side):

<code>
(function main(_) {
  function hugo(_) {
    var __frame = {
      name: "hugo",
      line: 3
    };
    return __func(_, this, arguments, hugo, 0, __frame, function __$hugo() {
      let Result = 1;
      return _(null, Result);
    });
  };
  var __frame = {
    name: "main",
    line: 1
  };
  return __func(_, this, arguments, main, 0, __frame, function __$main() {
    return hugo(__cb(_, __frame, 7, 19, function ___(__0, __1) {
      return demo(("Result = " + __1), __cb(_, __frame, 7, 0, function __$main() {
        _();
      }, true));
    }, true));
  });
}).call(this, __trap);
</code>

which still looks fine.

But trying to "execute" that code leads to an error message:

Expected an identifier but found 'Result' instead

Bruno Jouhier

unread,
Apr 4, 2014, 6:25:17 PM4/4/14
to stream...@googlegroups.com
It should work in node.js but you need two things:
  • add a "use strict"; directive at the top of your module
  • run pass the two --nodejs --harmony options to _node

Bruno

Reply all
Reply to author
Forward
0 new messages