Lasso Soft Inc. > Home

[ capture ]

Type

A capture is a block of Lasso code that can be passed to another method or invoked locally. Captures are context aware and depending on the scope have access to the current locals and self. Captures are denoted by { } brackets, by {^ ^} brackets, and are generated when using the "container" syntax. For example:

if (true)

something

/if

The above creates a capture between the if() /if.

Captures are a core component of the language and in many ways are transparent in typical usage.

  • Syntax
  • Methods
  • Traits
{ }
{^ ^}
foo();

/foo;
Has methods:
Examples
  • Beginner
  • Intermediate
  • Advanced

Captures are used transparently by container methods.

Here the code within the inline will be passed to the inline method as a capture.

Code

inline(-database='lasso_email',-table='smtp_queue',-show) 
      local(columns = column_names)
/inline
#columns

Result

staticarray(id, id_site, id_route, id_cache, mime_text, mime_recipients, mime_from, smtp_host, smtp_port, smtp_timeout,
smtp_username, smtp_password, smtp_ssl, queue_date, queue_status, queue_error, queue_number, queue_priority,
queue_retries, merge_array, merge_tokens, create_date)

A capture being passed the inline method.

Code

inline(-database='lasso_email',-table='smtp_queue',-show) => {
      local(columns = column_names)
}
#columns

Result

staticarray(id, id_site, id_route, id_cache, mime_text, mime_recipients, mime_from, smtp_host, smtp_port, smtp_timeout,
smtp_username, smtp_password, smtp_ssl, queue_date, queue_status, queue_error, queue_number, queue_priority,
queue_retries, merge_array, merge_tokens, create_date)

Invoke a capture block

Code

{ return 'hello' }->invoke

Result

hello

A counter implemented with a capture.

Code

local(i=1)
{  
   #i = #i + 1
   #i < 10 ? currentcapture->restart
}()

#i

Result

10

Recent Comments

No Comments found

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft