Closed yuri-karadzhov closed 11 years ago
You can change the style of runtime with the -I
flag to the iced
interpreter/compiler, but the runtime is needed, there's no way around that.
Yes, it works, but you should change the documentation. Because it says that -I node is default setting (but it is -I none)
For me the default behavior is -I node
. Which version are you using? Can you copy in the results of iced --print x.iced
for some trivial x.iced
? Thanks Yuri.
$ node --version
v0.8.15
$ npm --version
1.1.66
$ npm ls iced-coffee-script
skwibl@0.5.1 /var/www/skwibl
└── iced-coffee-script@1.4.0a
$ uname -a
Linux tower 3.6.9-030609-generic #201212031610 SMP Mon Dec 3 21:11:48 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
$ cat test.iced
parallelSearch = (keywords, cb) ->
out = []
await
for k,i in keywords
search k, defer out[i]
cb out
$ iced -bp test.iced
var parallelSearch, __iced_k, __iced_k_noop;
__iced_k = __iced_k_noop = function() {};
parallelSearch = function(keywords, cb) {
var i, k, out, ___iced_passed_deferral, __iced_deferrals, __iced_k,
_this = this;
__iced_k = __iced_k_noop;
___iced_passed_deferral = iced.findDeferral(arguments);
out = [];
(function(__iced_k) {
var _i, _len;
__iced_deferrals = new iced.Deferrals(__iced_k, {
parent: ___iced_passed_deferral,
filename: "test.iced",
funcname: "parallelSearch"
});
for (i = _i = 0, _len = keywords.length; _i < _len; i = ++_i) {
k = keywords[i];
search(k, __iced_deferrals.defer({
assign_fn: (function(__slot_1, __slot_2) {
return function() {
return __slot_1[__slot_2] = arguments[0];
};
})(out, i),
lineno: 5
}));
}
__iced_deferrals._fulfill();
})(function() {
return cb(out);
});
};
$ iced -bp test.iced > test_default.js
$ iced -I node -bp test.iced > test_node.js
$ diff test_default.js test_node.js
1c1
< var parallelSearch, __iced_k, __iced_k_noop;
---
> var iced, parallelSearch, __iced_k, __iced_k_noop;
2a3
> iced = require('iced-coffee-script').iced;
This makes sense --- the -b
option implies -I none
. Thanks for your feedback.
I've got a problem when I tried to compile *.iced file (with await deffer functions) to javascript. It compiled without an errors, but contains iced object variable. So when I tried to run it with node I've got an error because this variable is undefined.
It can be fixed with one line in the head of the file iced = require('iced-coffee-script').iced
but it's really annoying to add such line to every file with await-deffer pair.