until = fun: (b, c) ->
while({ not(b()) }):
c()
Animal = class:
__init__ = (name) ->
self.name = name
make_sound = ->
print('Generic animal noise.')
Dog = class(Animal):
make_sound = ->
print('Woof.')
Cat = class(Animal):
make_sound = ->
print('Meow.')
SlashProgSlasher = class(Animal):
make_sound = ->
print('Read SICP')
haskell = Dog('Haskell')
haskell.make_sound()
read_sicp = False
days_until_sicp = 10
slash_prog_slasher = SlashProgSlasher('Anonymous')
until({ read_sicp }):
slash_prog_slasher.make_sound()
if days_until_sicp == 0:
print 'SICP read!'
break
print('%i days until SICP.' % [days_until_sicp])
days_until_sicp -= 1
It's FIOC without statements like
>>7, but it's more like Scheme because you can pretty much do anything with it. Oh and
foo(...):
bar
is short for
foo(..., {bar}). Not too keen on how while/until look and I'm not sure how to make 'break' work, but I like it.