TT3: /home/abw/web/london/tt3/slides/examples/functions.tt3

Template Source

[% foo() # called in scalar context by default foo # called via textification bar = foo # bar is a reference to foo bar() # calling foo via bar alias baz(foo, bar) # passes function references baz(foo(), bar()) # calls foo() and bar first %] --EOF--

Source Tokens

tag_start@0[%
whitespace@2\n
variable@7foo
variable apply@10(
terminator@11)
whitespace@12 # called in scalar context by default\n\n
variable@70foo
whitespace@73 # called via textification\n\n
variable@122bar
whitespace@125
operator assign@126=
whitespace@127
variable@128foo
whitespace@131 # bar is a reference to foo\n
variable@174bar
variable apply@177(
terminator@178)
whitespace@179 # calling foo via bar alias\n\n
variable@227baz
variable apply@230(
variable@231foo
separator@234,
whitespace@235
variable@236bar
terminator@239)
whitespace@240 # passes function references\n
variable@280baz
variable apply@283(
variable@284foo
variable apply@287(
terminator@288)
separator@289,
whitespace@290
variable@291bar
variable apply@294(
terminator@295)
terminator@296)
whitespace@297 # calls foo() and bar first\n\n
tag_end@329%]
text@331\n
eof@332

Parse Tree

sub keyword@10foo()
Call
variable element@7foo
Args
variable element@70foo
binary expr@126bar = foo
variable element@122bar
=
variable element@128foo
sub keyword@177bar()
Call
variable element@174bar
Args
sub keyword@230baz(foo; bar)
Call
variable element@227baz
Args
variable element@231foo
variable element@236bar
sub keyword@283baz(foo(); bar())
Call
variable element@280baz
Args
sub keyword@287foo()
Call
variable element@284foo
Args
sub keyword@294bar()
Call
variable element@291bar
Args
text@331\n

Variables Used

bar
Uses
@ line 6 bar = foo # bar is a reference to foo
@ line 7 bar() # calling foo via bar alias
@ line 9 baz(foo, bar) # passes function references
@ line 10 baz(foo(), bar()) # calls foo() and bar first
baz
Uses
@ line 9 baz(foo, bar) # passes function references
@ line 10 baz(foo(), bar()) # calls foo() and bar first
foo
Uses
@ line 2 foo() # called in scalar context by default
@ line 4 foo # called via textification
@ line 6 bar = foo # bar is a reference to foo
@ line 9 baz(foo, bar) # passes function references
@ line 10 baz(foo(), bar()) # calls foo() and bar first

Generated Output

TT3 undefined data error at line 2 of /home/abw/web/london/tt3/slides/examples/functions.tt3:
Error: Undefined value returned by expression: foo()
Source: foo() # called in scalar context by default
^ here