呵呵,是关于lua stdlib 库的set模块的bug,其实作者好像确认很久了。。。。但是我这段时间一直没有上gmail,所以没有看到。。。作者说,在新版中已经修改此bug...今天下了最新版,发现真是这样:)呵呵,真高兴啊,吸收了开源社区的那么多营养。。。总算有点报答了。。。当然,这仅仅是起步:)
实际流程贴一下。。。满足一下虚荣心。。。其实仅仅是一个很小的很容易发现的bug。。。呵呵,我当时学lua才一两周。。也不可能发现多么难的bug....lol
原来的lua stdlib set中某段程序如下:
-
--@funcpropersubset:Findwhetheroneset
is
apropersubsetof
-
--another
-
--@params,t:sets
-
--@returns
-
--@paramr:true
if
s
is
apropersubsetoft,falseotherwise
-
functionpropersubset(s,t)
-
return
subset(s,t)
and
not
subset(t,s)
-
end
-
-
--@funcequal:Findwhethertwosetsareequal
-
--@params,t:sets
-
--@returns
-
--@paramr:true
if
setsareequal,falseotherwise
-
functionequal(s,t)
-
return
subset(s,t)
and
subset(s,t)
-
end
-
-
--@headMetamethods
for
sets
-
--set+table=union
-
metatable.__add=union
-
--set-table=setdifference
-
metatable.__sub=difference
-
--set/table=intersection
-
metatable.__div=intersection
-
--set<=table=subset
-
metatable.__le=subset
-
于是我发邮件给作者
hi all,
Thank you very much for your hard working with the LuaForWindows,I enjoy it so mush.
there is a bug to report as my return.
the set.lua file in the lualibs, 117th line.
source as this code:"return subset (s, t) and subset (s, t)"
it obviously should be "return subset (s,t) and subset(t, s)"
which means they are equal when s is the subset t and t is the subset s.
I hope I'm right and didn't disturb you.
BTW,there is a surprising attribute.
In the set's operations,div(/) mean intersection that is different from custom.
In the custom mul(*) denotes it,just like the <<programming in Lua>> writes in the 13th captial named "metatable and meatmethod"
Thank you for readingmy poor Chinglish. lol,I'mChinese.
Best wishes.
your honest
JTianLing from jtianling{at}gmail.com
luaforwindows的作者回信
Andrew Wilson to me, rrt, luaforwindows
show details Sep 3 Reply
Thanks for the bug report JTianLing, this particular module comes from
the stdlib library , I'll copy your report of this issue to the
administrator of that project http://luaforge.net/projects/stdlib/
.
Your English is great, you wouldn't want to even hear my Mandarin.
关心
Andrew Wilson
呵呵,不知道他这里说关心是什么意思......,惊奇的是。。。。他竟然还真能打中文字。。。。E文系统应该是没有中文输入法的吧。。。。
最后lua stdlib的作者回信:
Reuben Thomas to Andrew, me, luaforwindows
show details Sep 4 Reply
Thanks, this is quite correct. I've made a new release with this fix.
I see, I had actually forgotten that * is used in Modula-3 in the same way. I am happy to change this so that * is intersection and / is symmetric difference.
Thanks, I've made another release with these changes, and coincidentally fixed set.difference, which was also broken.
呵呵,最新版的set如下,可见已经修复,并且连那个我称为surprising attribute 的“/”符号表示交集也改了:)
-
--@funcintersection:Findtheintersectionoftwosets
-
--@params,t:sets
-
--@returns
-
--@paramr:setintersectionofs
and
t
-
functionintersection(s,t)
-
localr=new{}
-
for
e
in
elements(s)do
-
if
member(t,e)then
-
insert(r,e)
-
end
-
end
-
return
r
-
end
-
-
--@funcunion:Findtheunionoftwosets
-
--@params,t:sets
-
--@returns
-
--@paramr:setunionofs
and
t
-
functionunion(s,t)
-
localr=new{}
-
for
e
in
elements(s)do
-
insert(r,e)
-
end
-
for
e
in
elements(t)do
-
insert(r,e)
-
end
-
return
r
-
end
-
-
--@funcsubset:Findwhetheroneset
is
asubsetofanother
-
--@params,t:sets
-
--@returns
-
--@paramr:true
if
s
is
asubsetoft,falseotherwise
-
functionsubset(s,t)
-
for
e
in
elements(s)do
-
if
not
member(t,e)then
-
return
false
-
end
-
end
-
return
true
-
end
-
-
--@funcpropersubset:Findwhetheroneset
is
apropersubsetof
-
--another
-
--@params,t:sets
-
--@returns
-
--@paramr:true
if
s
is
apropersubsetoft,falseotherwise
-
functionpropersubset(s,t)
-
return
subset(s,t)
and
not
subset(t,s)
-
end
-
-
--@funcequal:Findwhethertwosetsareequal
-
--@params,t:sets
-
--@returns
-
--@paramr:true
if
setsareequal,falseotherwise
-
functionequal(s,t)
-
return
subset(s,t)
and
subset(t,s)
-
end
-
-
--@headMetamethods
for
sets
-
--set+table=union
-
metatable.__add=union
-
--set-table=setdifference
-
metatable.__sub=difference
-
--set*table=intersection
-
metatable.__mul=intersection
-
--set/table=symmetricdifference
-
metatable.__div=symmetric_difference
-
--set<=table=subset
-
metatable.__le=subset
-
--set<table=propersubset
-
metatable.__lt=propersubset
这虽然是一件芝麻一样的小事,但却是我个人第一次真正的为开源社区做贡献。。。。虽然仅仅是以bug report的形式:)立此存照:)
分享到:
相关推荐
lua5.3(32位/64位)windows 预编译(exe/DLL) adding: lua5.3.5-x86/lua.exe (in=14336) (out=7311) (deflated 49%) adding: lua5.3.5-x86/lua.o (in=24873) (out=9654) (deflated 61%) adding: lua5.3.5-x86/lua...
当前版本除了前面几个版本中更新的内容之外,还增加了宏 LUA_COMPAT_5_2 定义修改。 在源码包中,此宏定义在GCC中,打开lua-5.3.4/src/Makefile,可以看到:CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS...
C++ lua Kaguya 应用
压缩包中包含lua开源软件 lua-5.3.4.tar.gz,与lua中文手册 Lua-5.3中文手册.pdf
lua:一个交互式解释器工具,支持脱离宿主应用环境的简单脚本独立执行。 PS : Lua版本 5.2.1 是我从http://www.lua.org上到的目前最新的版本 PSPS : 如果不想自行编译Lua库及工具。可以下载一个Windows上预编译好的...
(阿里云负载均衡)或者 lvs+Tengine(nginx)+lua防护攻击(获取用户真实ip):线上正式使用,可以修改lua达到自己想要效果; 记得修改以下获取真实ip function getClientIp() IP = ngx.var....
”这一行前添加注释符“ ” 然后在文件的最后添加一行 dofile "rtp h264 lua" 这样 Wireshark 启动时就会自动调用 rtp h264 lua 4 最后打开wireshark 在菜单Edit >Preferences >RTP PAYLOAD中...
直接以JNI方式调用Lua解析引擎的接口十分麻烦,开源项目LuaJava(https://github.com/mkottman/AndroLua )对这些JNI接口进行了很好的封装,它是一个包含了LuaJava的Android平台的Lua解析器,它提供一系列映射到Lua ...
介于许多小伙伴 打开lua官网很慢,下载lua源代码很慢,传一个lua5.4.6最新版本的源代码
lua-nginx-module-0.10.13
表情符号 :speech_balloon:Lua的基本表情符号支持模块 :crescent_moon:例子 local emoji = require ( " emoji " )print (emoji. emojify ( " I :heart: :tea:! " ))-- > "I :red_heart: :teacup_without_handle:!...
所有版本LUA源码 lua-5.3.5 lua-5.3.4 lua-5.3.3 lua-5.3.2 lua-5.3.1 lua-5.3.0 lua-5.2.4 lua-5.2.3 lua-5.2.2 lua-5.2.1 lua-5.2.0 lua-5.1.5 lua-5.1.4 lua-5.1.3 lua-5.1.2 lua-5.1.1 lua-5.1 lua-5.0.3 lua-...
lua 5.2 中GOTO语句的使用lua 5.2 中GOTO语句的使用
德皮菲菲尔将PICO-8样式的Lua语法转换/转换为标准的干净Lua语法。 在此处下载。 该工具使用经过来解析PICO-8源代码,因此任何增强的或特殊的语法或速记方式都只会在应有的位置进行转换。 如果您喜欢这个工具,请考虑...
Lua 是一个小巧的脚本语言。作者是巴西人。该语言的设计目的是为了嵌入应用程序中,从而为应用程序提供灵活的扩展和定制功能。 Lua脚本可以很容易的被C/C++代码调用,也可以反过来调用C/C++的函数,这使得Lua在应用...
test pc: ubuntu 14.04 lua : 5.3.0 tools: bash, make demos: 1. test.lua ## hello world 2. function.lua ## 函数调用 3. param.lua ## 函数参数, 4. table ## table ...works/lua_demo$ lua test.lua
lua-resty-http:用于OpenResty ngx_lua的Lua HTTP客户端cosocket驱动程序
LuaSeel是使用字节码加密的简单lua混淆器。 指示 转到lua在线执行器(即repl.it,lua演示等)。 复制并粘贴此脚本到执行程序中: : 转到第2行,并将其替换为您要混淆的脚本。 执行脚本,混淆的脚本将出现在输出...
LuaHelper:luahelper一个高性能的lua插件,用于lua的语言服务器协议
lua解析器,方便lua开发