#!/usr/bin/env python """ exclaim.py - Pluvo Standard Library: exclaim Author: Joe Geldart, durham.ac.uk Author: Sean B. Palmer, inamidst.com Cf. http://paste.lisp.org/display/21936 Note, Joe wants to use "!" for this function; how does this interact with ! being not? Is there a context in which the use of ! can be determined? Possibly arg length for example? Better would likely be to merge this in with method. See for example: http://paste.lisp.org/display/21937#1 """ try: from basics import method from datatypes import Table, Symbol except ImportError: from pluvo.basics import method from pluvo.datatypes import Table, Symbol def exclaim(env, *args): """@exclaim param1: var1 param2: var2 block""" if len(args) < 3: raise ValueError("Action must have at least one symbol and a block") # If we only have one symbol, we're a predicate without parameter if len(args) == 3: predsym, question, block = args method(env, predsym, Symbol("="), Table(), block) else: symname = "" argspec = Table() args, block = args[:-1], args[-1] while args: (arg, colon, var), args = args[:3], args[3:] # print arg, colon, var symname += arg.name argspec.append(var) actsym = Symbol(symname) method(env, actsym, Symbol("="), argspec, block) main = exclaim if __name__ == '__main__': print __doc__