lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


PA wrote:

"La perfection est atteinte non quand il ne reste rien à ajouter, mais quand il ne reste rien à enlever."


I admire perfection and aspire to remove all that can be removed. It is a general concept, not a law of nature.

The colon is no more superfluous than is the dot.

Usefulness is the measure of tools.

I simply disagree with your assessment of its usefulness.

I will agree with you that forcing the use of the colon in the io library isn't very good. io.read(formats) should be io.read(file, formats), perhaps defaulting to the current behavior when a single string parameter is present. If colons are to be required in the standard library, then all items that return handles should enforce the use of colons - like coroutines. But I'd prefer a change to io.read(), io.write(), etc.

If you really want to get rid of your colons and dots, do something like this:

io_read=io["read"]
io.read = function (file, formats)
  if (io["type"](file) == 'file') then
    return file:read(formats)
  else
     return io_read(formats)
  end
end

file=assert(io["open"]("lilprince.txt", "rt"))
s=io["read"](file, '*l')
io["close"](file)
print(string["len"](s),s)
103 La perfection est atteinte non quand il ne reste rien à ajouter, mais quand il ne reste rien à enlever.

Not a single superfluous dot or colon in there! :)

Like bitwise operators and hexadecimal, I will change what I don't like. You may wish to consider doing the same.

Doug

--
--__-__-____------_--_-_-_-___-___-____-_--_-___--____
Doug Rogers - ICI - V:703.893.2007x220 www.innocon.com
-_-_--_------____-_-_-___-_--___-_-___-_-_---_--_-__-_