Hi David,

On 25 March 2016 at 14:49, David Favro <pros...@meta-dynamic.com> wrote:
> Hello,
> Here is a small patch to (partially, anyhow) remove prosody's
> reliance on Lua's implicit string-to-number coercion 'feature'.
> Why do so?  Since it was met with some disapproval in the
> chatroom, let me try to justify it here:

For what it's worth I'm not a fan of implicit coercion either, and I'd
say that we already actively avoid it much of our code already. I
wouldn't be sad to see automatic string->number coercion removed from

> This is perhaps not the only place where the code relies on this
> behavior, but it's the only one that I've found to date, and
> rather than sit on a patched local version, I'd prefer to run a
> vanilla codebase.  I am unfamiliar with hg; this patch is
> formatted such that the entire email can be fed to
> "git am --scissors" to apply it, while ignoring the rest of the
> email body; should you decide to use it, I don't know what is
> the equivalent with hg or whether the format is appropriate.

No worries, your contribution is appreciated in any format! Obviously
hg makes life easier for us, but for the odd patch anything is fine
(though I'm probably opening myself up to screenshots of code embedded
in Word documents at this point).

Ultimately, I didn't apply your patch as-is though. Reasoning follows:

As well as adding tonumber() (the main reason for the patch) it subtly
changed the major + minor calculation. While the new calculation
produced the same result for current LuaSec version numbers (0.4, 0.5,
0.6), it wasn't quite the same calculation. Specifically the new one
would treat "0.1" and "0.10" the same (returning 1 for both). Notably
the current code actually has a similar issue (it's not perfect), but
is good for up to 0.100 which is probably some time away yet...

Therefore I simply changed the code to call tonumber() on both
segments of the version number, and left the existing calculation code
in place. See https://hg.prosody.im/0.10/rev/afa83f3ccaad



You received this message because you are subscribed to the Google Groups 
"prosody-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prosody-dev+unsubscr...@googlegroups.com.
To post to this group, send email to prosody-dev@googlegroups.com.
Visit this group at https://groups.google.com/group/prosody-dev.
For more options, visit https://groups.google.com/d/optout.

Reply via email to