[Rpm-maint] [rpm-software-management/rpm] Implement simple macro objects (PR #1826)
Michael Schroeder
notifications at github.com
Sat Nov 13 23:46:22 UTC 2021
Or:
```
%define colors[array]
```
I've also created an alternative implementation that uses real lua objects. It works like this:
```
%define luamethod.Array._init { self:push(arg) }
%define luamethod.Array.push { for _,v in ipairs(arg) do ; table.insert(self, v) ; end }
%define luamethod.Array._expand { print(table.concat(self, " ")) }
```
The special `luamethod.` prefix tells %define that this defines a class method. That way the definition can also be in the macros file:
```
%luamethod.Array._init { self:push(arg) }
...
```
As with the other implementation, you can then do:
```
%defineobject foo(Array) first second
%{foo push bar}
%{foo push baz}
%foo
```
and get `first second bar baz`.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/1826#issuecomment-968176249
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20211113/e4dbf54a/attachment-0001.html>
More information about the Rpm-maint
mailing list