[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Overloaded conditional operators in Lua
- From: Gopalakrishnan Subramani <gopalakrishnan.subramani@...>
- Date: Thu, 11 Nov 2010 10:43:35 +0530
We have Lua table definition like this.
DeviceTag = VARIABLE
name = "DeviceTag",
data_type = Float,
address = 100
We have written data access layer which shall be used like this.
the function Read is written in C++(COM)/C#. It reads the value from device and set the value to DeviceTag
DeviceTag.value = <<Data read from device>>
We will be using the DeviceTag.value for arithmetic operations, comparisons.
Now the question is, how do I access the value attribute without mentioning it.
if (DeviceTag == "Krish") then
do something here
Whereas when I say DeviceTag during comparison, it should provide me the DeviceTag.value by default.
Something like operator overload is possible to get this? Our attempt is, there a Device Description Language available and we want to generate our Lua code from existing Device Description Language.
I know Lua is general purpose and DSL defined must confirm Lua syntax. I am curious to learn Lua and creating DSL for our company.