Here's the standard example:
var x = "bar";
(function() {
console.log(x) // undefined
var x = 42;
})()
But what happens when you have a parameter?
macro _match_cond { | |
case $o ($field) => { | |
(typeof $o.$field !== 'undefined') | |
} | |
case $o ($field $rest ...) => { | |
_match_cond $o ($field) && _match_cond $o ($rest ...) | |
} | |
} | |
macro _match_var { |
macro class { | |
case $className { constructor $constParam $constBody $rest ... } => { | |
function $className $constParam $constBody | |
class $className { $rest ... } | |
} | |
case $className { private_function $pMethodName $pMethodParam $pMethodBody $rest ...} => { | |
function $pMethodName $pMethodParam $pMethodBody | |
class $className { $rest ... } |
sed ' | |
s/^>// | |
t | |
s/^ *$// | |
t | |
s/^/-- / | |
' in.lhs > out.hs |
defaults write -app Skim SKAutoReloadFileUpdate -boolean true |
macro null_helper { | |
case ($processed ...) ($rest) => { | |
$processed (.) ... . $rest | |
} | |
case ($processed ...) ($rest_head $rest ...) => { | |
$processed (.) ... . $rest_head | |
&& null_helper ($processed ... $rest_head) ($rest ...) | |
} | |
} |
macro def { | |
case $name:ident ( $($params:ident : $type:ident) (,) ...) $body => { | |
// just throwing away the type annotation. The semantics of type | |
// annotations left as an exercise to the reader :) | |
function $name ($params (,) ...) $body | |
} | |
} | |
def add (a : Number, b : Number) { | |
return a + b; |
macro conspair { | |
case [$head] => { [$head] } | |
case [$head $tail ...] => { | |
[$head, conspair [$tail ...]] | |
} | |
} | |
conspair [1 2 3 4] |
macro sexp { | |
case () => { | |
; | |
} | |
case ($p) => { | |
$p | |
} | |
case ($x $y) => { | |
$x($y); | |
} |
Here's the standard example:
var x = "bar";
(function() {
console.log(x) // undefined
var x = 42;
})()
But what happens when you have a parameter?
/* | |
* grunt | |
* https://github.com/cowboy/grunt | |
* | |
* Copyright (c) 2012 "Cowboy" Ben Alman | |
* Copyright (c) 2012 John K. Paul @johnkpaul | |
* Licensed under the MIT license. | |
* http://benalman.com/about/license/ | |
*/ |