`
webcenterol
  • 浏览: 913753 次
文章分类
社区版块
存档分类
最新评论

真高兴啊。。。。实际的为开源事业做了点点贡献:),很久前指出的一个lua stdlib的bug得到确认

 
阅读更多

呵呵,是关于lua stdlib 库的set模块的bug,其实作者好像确认很久了。。。。但是我这段时间一直没有上gmail,所以没有看到。。。作者说,在新版中已经修改此bug...今天下了最新版,发现真是这样:)呵呵,真高兴啊,吸收了开源社区的那么多营养。。。总算有点报答了。。。当然,这仅仅是起步:)

实际流程贴一下。。。满足一下虚荣心。。。其实仅仅是一个很小的很容易发现的bug。。。呵呵,我当时学lua才一两周。。也不可能发现多么难的bug....lol

原来的lua stdlib set中某段程序如下:

  1. --@funcpropersubset:Findwhetheroneset is apropersubsetof
  2. --another
  3. --@params,t:sets
  4. --@returns
  5. --@paramr:true if s is apropersubsetoft,falseotherwise
  6. functionpropersubset(s,t)
  7. return subset(s,t) and not subset(t,s)
  8. end
  9. --@funcequal:Findwhethertwosetsareequal
  10. --@params,t:sets
  11. --@returns
  12. --@paramr:true if setsareequal,falseotherwise
  13. functionequal(s,t)
  14. return subset(s,t) and subset(s,t)
  15. end
  16. --@headMetamethods for sets
  17. --set+table=union
  18. metatable.__add=union
  19. --set-table=setdifference
  20. metatable.__sub=difference
  21. --set/table=intersection
  22. metatable.__div=intersection
  23. --set<=table=subset
  24. 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 的“/”符号表示交集也改了:)

  1. --@funcintersection:Findtheintersectionoftwosets
  2. --@params,t:sets
  3. --@returns
  4. --@paramr:setintersectionofs and t
  5. functionintersection(s,t)
  6. localr=new{}
  7. for e in elements(s)do
  8. if member(t,e)then
  9. insert(r,e)
  10. end
  11. end
  12. return r
  13. end
  14. --@funcunion:Findtheunionoftwosets
  15. --@params,t:sets
  16. --@returns
  17. --@paramr:setunionofs and t
  18. functionunion(s,t)
  19. localr=new{}
  20. for e in elements(s)do
  21. insert(r,e)
  22. end
  23. for e in elements(t)do
  24. insert(r,e)
  25. end
  26. return r
  27. end
  28. --@funcsubset:Findwhetheroneset is asubsetofanother
  29. --@params,t:sets
  30. --@returns
  31. --@paramr:true if s is asubsetoft,falseotherwise
  32. functionsubset(s,t)
  33. for e in elements(s)do
  34. if not member(t,e)then
  35. return false
  36. end
  37. end
  38. return true
  39. end
  40. --@funcpropersubset:Findwhetheroneset is apropersubsetof
  41. --another
  42. --@params,t:sets
  43. --@returns
  44. --@paramr:true if s is apropersubsetoft,falseotherwise
  45. functionpropersubset(s,t)
  46. return subset(s,t) and not subset(t,s)
  47. end
  48. --@funcequal:Findwhethertwosetsareequal
  49. --@params,t:sets
  50. --@returns
  51. --@paramr:true if setsareequal,falseotherwise
  52. functionequal(s,t)
  53. return subset(s,t) and subset(t,s)
  54. end
  55. --@headMetamethods for sets
  56. --set+table=union
  57. metatable.__add=union
  58. --set-table=setdifference
  59. metatable.__sub=difference
  60. --set*table=intersection
  61. metatable.__mul=intersection
  62. --set/table=symmetricdifference
  63. metatable.__div=symmetric_difference
  64. --set<=table=subset
  65. metatable.__le=subset
  66. --set<table=propersubset
  67. metatable.__lt=propersubset

这虽然是一件芝麻一样的小事,但却是我个人第一次真正的为开源社区做贡献。。。。虽然仅仅是以bug report的形式:)立此存照:)

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics