diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2020-01-10 20:13:06 +0100 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2020-01-11 19:38:27 +0100 |
commit | e98921ae571717d3d7c1fbaf7d7d527361b664c9 (patch) | |
tree | ae6886402a129baa0b69e4ce6d461486a760ffda /data | |
parent | 57637f8aae6172e7713e885f41f4574cfa2770b3 (diff) | |
download | pandoc-e98921ae571717d3d7c1fbaf7d7d527361b664c9.tar.gz |
pandoc.List.lua: make `pandoc.List` a callable constructor
It is now possible to construct a new List via `pandoc.List()` instead of
`pandoc.List:new()`.
Diffstat (limited to 'data')
-rw-r--r-- | data/pandoc.List.lua | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/data/pandoc.List.lua b/data/pandoc.List.lua index 6b3188a65..442e9c397 100644 --- a/data/pandoc.List.lua +++ b/data/pandoc.List.lua @@ -1,28 +1,27 @@ --[[ List.lua -Copyright © 2017–2018 Albert Krewinkel +Copyright © 2017–2020 Albert Krewinkel -Permission to use, copy, modify, and/or distribute this software for any purpose -with or without fee is hereby granted, provided that the above copyright notice -and this permission notice appear in all copies. +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS -OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. -]] +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ]] --- Pandoc's List type and helper methods -- @classmod pandoc.List -- @author Albert Krewinkel --- @copyright © 2017–2018 Albert Krewinkel +-- @copyright © 2017–2020 Albert Krewinkel -- @license MIT local List = { - _VERSION = "0.1.0" + _VERSION = "1.0.0" } function List:new (o) @@ -32,10 +31,6 @@ function List:new (o) return o end -function List:__call (o) - return self:new(o) -end - --- Concatenates two lists. -- @param list second list concatenated to the first -- @return a new list containing all elements from list1 and list2 @@ -117,4 +112,11 @@ function List:filter (pred) return res end +-- Set metatable with __call metamethod. This allows the use of `List` +-- as a constructor function. +local ListMT = { + __call = List.new +} +setmetatable(List, ListMT) + return List |