lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

The following class overrides the concat operator,
however using it, as one can use a string, produces 
`=' expected near `..'

How to achive this?

Note I don't need the result of the concat, as
eventually, the side effect of "chaining" will 
produce the results required.

-- Chain Class

function Chain_concat( a, b )
  return b;

Chain      = {};
Chain_Meta = {
  __index  = Chain;
  __concat = Chain_concat;

function Chain:new()
  local chain  = {};
  chain.ichain = nil;
  setmetatable( chain, Chain_Meta );
  return chain;

function Chain:link( a, b )
  if ( nil ~= b.ichain ) then
    error( "chain already linked" );
  b.ichain = a;

-- use chain

  achain = Chain:new();
  bchain = Chain:new();
  achain .. bchain;

-- Paul Matthews
This email is intended for the use of the individual addressee(s) named above and may contain information that is confidential, privileged or unsuitable for overly sensitive persons with low self-esteem, no sense of humour or irrational religious beliefs. If you are not the intended recipient, any dissemination, distribution  or copying of this email is not authorised (either explicitly or implicity) and constitutes an irritating social faux pas. - Yahoo! Personals
New people, new possibilities. FREE for a limited time.