geopro:pedro:tmedisc
Diferenças
Aqui você vê as diferenças entre duas revisões dessa página.
Próxima revisão | Revisão anterior | ||
geopro:pedro:tmedisc [2010/05/19 13:09] – created pedro | geopro:pedro:tmedisc [2010/06/29 21:10] (atual) – pedro | ||
---|---|---|---|
Linha 1: | Linha 1: | ||
- | ====Operador # para CS, Neighborhood==== | + | ====Observer==== |
+ | observer(cell) que não recebe um atributo, e sim uma função que retorna o valor a ser usado. | ||
- | toda metatable pode ter um operador " | + | ====Save==== |
- | para tabelas, | + | * Ver a questão temporal abaixo. |
+ | * Ao invés de receber | ||
+ | |||
+ | ====Questões temporais==== | ||
+ | * Quando tiver o current simulation time como valor global, verificar os save para que time tenha como valor default o tempo atual. | ||
+ | * Para leitura de espaços celulares e de vizinhanças, | ||
+ | * A função config para um Event que está executando nao afeta o desenvolvimento deste mesmo evento no futuro. | ||
+ | |||
+ | ====Operador # para CellularSpace, Neighborhood==== | ||
+ | Fonte: | ||
+ | |||
+ | toda metatable pode ter um operador " | ||
+ | para tabelas, ele não tem como ser chamado: | ||
| | ||
Linha 20: | Linha 33: | ||
end | end | ||
end | end | ||
+ | |||
+ | De acordo com listas de e-mails, será possível fazer isto com [[http:// | ||
+ | |||
+ | ====__index and __newindex metamethods to Observing==== | ||
+ | Fonte: http:// | ||
+ | |||
+ | Lua defines two useful metamethods, | ||
+ | |||
+ | Example | ||
+ | |||
+ | a = {} | ||
+ | setmetatable(a, | ||
+ | a[1] = " | ||
+ | return a[2] -- This will call __index metamethods | ||
+ | return a[1] -- This will NOT call __index | ||
+ | |||
+ | The last line does not call index meta-method because a[1] does exists. This is a problem when you want to use table as object, because sometimes you want to monitor access to the table elements. | ||
+ | |||
+ | This can be easily worked around using a proxy system: you don't store things in the table you manipulate, but in another table. | ||
+ | |||
+ | a = {} | ||
+ | realtable = {} | ||
+ | setmetatable(a, | ||
+ | |||
+ | Where meta-methods are something like: | ||
+ | |||
+ | function myindexfunction(table, | ||
+ | return realtable[key] | ||
+ | end | ||
+ | |||
+ | function mynewindexfunction(table, | ||
+ | realtable[key] = value | ||
+ | end | ||
+ | |||
+ | This way, our a table will always be empty, and realtable will have the data. At every read or write access to a, the meta-methods will be called. This is very convenient and widely used hack. | ||
geopro/pedro/tmedisc.1274274541.txt.gz · Última modificação: 2010/05/19 13:09 por pedro