This is a guide to the basic program functions, operators, and variables of Pluvo. These are all accessible as variables without the "@" namespace sigil. For an introduction to Pluvo, try the Guide to Pluvo instead. Feel free to ask questions about this document on the Pluvo mailing list.
>> add people "Alice" >> add people "Bob"
>> if {return false} { say "FAIL" } >> else { say "pass" } pass
>> hello = (name) >> example >> hello "Alice" >> => Hello, Alice! >> >> say "Hello, $name!"
>> for ("Alice" "Bob") >> say "Hello $arg" Hello Alice Hello Bob >> for name ("Alice" "Bob") >> say "Hi $name" Hi Alice Hi Bob >> for language in ("Perl" "PHP" "Python") >> say "$language is a language" Perl is a language PHP is a language Python is a language >> for (p q) in (("p" "q") ("r" "s") (7 8)) >> say "$p -> $q" p -> q r -> s 7 -> 8
>> usage >> "033-test.pvo [options]" >> -h/--help "Display a help message" >> -t/--test "Perform builtin code tests" >> help 033-test.pvo [options] -h/--help Display a help message -t/--test Perform builtin code tests
>> if {return true} { say "pass" }
>> join " " ("Hello" "there") Hello there >> "..." join (1 2 3) 1...2...3
>> Person = (name homepage) >> method details = () >> say "Name: $name" >> say "Homepage: $homepage" >> jc = Person("Cody Woodard" "http://d8uv.org/") >> jc.details Name: Cody Woodard Homepage: http://d8uv.org/
>> if {not true} { say "FAIL" } >> if {not false} { say "pass" } pass
>> if {/123/ "pqr"} { say "FAIL" } >> or if {/pqr/ "pqr"} { say "pass" } pass
>> out "Hello, world!\n" Hello, world! >> out "p" "q" "r\n" p q r
>> say "pass" >> quit pass >> say "FAIL" >> quit 1 FAIL
>> for i in { range 1 3 } >> say i 1 2 3 >> for i in { range 5 1 -2 } >> say "...$i" ...5 ...3
>> test = () >> return "pass" >> say "FAIL" >> say { test } pass
>> run { say "Testing" } Testing >> say { run "Hello, world!" } Hello, world!
>> say "Hello, world!" Hello, world! >> say 1 2 3 1 2 3 >> say { 3 + 5 } 8
>> main = (argv) >> say "Hello, world!" >> script main Hello, world!
>> split " " "Hello there" ("Hello" "there") >> "..." split "1...2...3" ("1" "2" "3")
>> usage >> "033-test.pvo [options]" >> -h/--help "Display a help message" >> -t/--test "Perform builtin code tests" >> help 033-test.pvo [options] -h/--help Display a help message -t/--test Perform builtin code tests
>> {block} = { 5 + 3 } >> say {{{ quote block }:0}:0} 5
>> hello = "Hello, world!" >> say hello Hello, world!If name appears within braces and the second argment is a block, assign the block to name without evaluating it. Example:
>> {block} = { 5 + 3 } >> say {{{ quote block }:0}:0} 5If there are two arguments, and the second argument is a Table, argspec, the the third argument a block, create a new function from block using the second argument as the argument specification. Example:
>> test = (name) >> say "Hello $name!" >> test "Alice" Hello Alice!Otherwise, if the second argument is a prototype, proto, and the third a Table of arguments, args, create a new copy of the prototype passing it the arguments. Example:
>> Dog = (name) >> method speak = (bark) >> say "$name says: " >> say "$bark! $bark! I am a dog." >> rover = Dog("Rover") >> rover.speak "WOOF" Rover says: WOOF! WOOF! I am a dog.
>> if {"something" == "something else"} { say "FAIL" } >> or if {"test" == "test"} { say "pass" } pass
>> say { "p" + "q" } pq >> say { + "p " "q " "r" } p q r >> say { 5 + 3 } 8
>> say { 8 - 3 } 5
@@ More.
$ pluvo test.pvo first second >> say { args:1 } first >> say { args:2 } second
$ pluvo test.pvo >> say "$prog" test.pvo
These functions and variables are just the variables that are available without using the program variables namespace sigil, "@". When using it, many more functions are available. There is some scant library documentation, but for more information on the library functions the best reference at the moment is the source itself.
Sean B. Palmer, inamidst.com