Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- keyword :: io.prompt('Enter search keyword: ')
- results :: server.find_results(type:'node', keyword:keyword)
- ; This is actually a pretty sweet but basic hack.
- ; ``function`` operates in the caller's scope and eats the next object, after
- ; checking that it is a code literal.
- ; (NOTE: may change this requirement to permit constructs such as
- ; ``code :: manipulate_code({blah() does() this()}) function(`a, `b) code``)
- ; If it is, ``function`` saves the code object and returns a new function that
- ; injects variables based upon the args passed to ``function`` and the function
- ; call and then executes the saved code object in a new scope.
- results.sort(key:(function(`r) {r.similarity}))
- ; A similar thing goes on here as to above, except that there is no new scope
- ; and the code is repeatedly re-run in the parent scope with just one variable
- ; re-set each time; the variable is populated using co-operative control flow
- ; passing with the passed function. When the function returns, the loops ends
- ; and the variable is cleaned up.
- foreach(`r, results.iter) {
- io.print(r.prettify())
- }
- ; Another sweet hack that allows some really interesting if-else constructs.
- ; Basic operation is pretty obvious, but what about elifs, or at least elses?
- ; ``if``, ``elif``, and ``else`` set a parent-scope variable upon exit (to
- ; allow nesting) that tells whether or not the condition was met.
- ; following ``elif``s or ``else``s will know whether or not execution is
- ; desired by inspecting that flag.
- if(verbose?) {
- io.print(server.debug_info())
- }
- else() {
- io.print('done.')
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement