Permalink
Browse files

Support self-describing built in fns.

* Add description to `write`.
  • Loading branch information...
1 parent 3865afc commit c5870c08583b2438eaaea664cbbe4c046fca0793 @maryrosecook committed Jan 11, 2013
Showing with 15 additions and 9 deletions.
  1. +1 −1 src/interpreter.js
  2. +14 −8 src/library.js
View
@@ -99,7 +99,7 @@
.when("invocation", function(ast, env) {
var fn = resolve({
ref: interpretAst(Isla.Parser.extract(ast, "invocation", 0), env)
- }, env);
+ }, env).fn;
var param = resolve(interpretAst(Isla.Parser.extract(ast,
"invocation", 1),
env).val, env);
View
@@ -20,15 +20,21 @@
exports.Library.getInitialEnv = function(extraTypes, initialCtx) {
var islaCtx = {
- write: function(env, param) {
- var out;
- if(Isla.Utils.type(param) === "Object") {
- out = param.toString();
- } else {
- out = param;
- }
+ write: {
+ fn: function(env, param) {
+ var out;
+ if(Isla.Utils.type(param) === "Object") {
+ out = param.toString();
+ } else {
+ out = param;
+ }
- return out;
+ return out;
+ },
+
+ description: function(p) {
+ return "Writes out " + p + ".";
+ }
},
_types: Isla.Utils.merge(extraTypes, {

0 comments on commit c5870c0

Please sign in to comment.