初心者の質問を許してください。しかし、coffee
REPL (または TextMate 内で作成および実行されるファイル) から (ほとんど) 標準関数を呼び出すことができないのはなぜですか?
変数の割り当ては機能しますが、関数は機能しません。
例:
coffee> string = "string"
'string'
coffee> list = [1,2,3]
[ 1, 2, 3 ]
coffee> num = 42
42
coffee> opposite = true
true
coffee> num = -42 if opposite
-42
しかし
coffee> alert "Hello, World"
ReferenceError: alert is not defined
at repl:1:5
at REPLServer.replDefaults.eval (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:33:28)
at repl.js:239:12
at Interface.<anonymous> (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:62:9)
at Interface.EventEmitter.emit (events.js:117:20)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:760:14)
at ReadStream.onkeypress (readline.js:99:10)
at ReadStream.EventEmitter.emit (events.js:117:20)
と
coffee> print "Hello"
ReferenceError: print is not defined
at repl:1:5
at REPLServer.replDefaults.eval (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:33:28)
at repl.js:239:12
at Interface.<anonymous> (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:62:9)
at Interface.EventEmitter.emit (events.js:117:20)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:760:14)
at ReadStream.onkeypress (readline.js:99:10)
at ReadStream.EventEmitter.emit (events.js:117:20)
本当に私を得るのは:
coffee> console.log "Help!"
Help!
undefined
Node は Homebrew 経由でインストールされ、CoffeeScript は (グローバルに) 経由でインストールされていnpm
ます。