erlyaws / yaws

Yaws webserver
https://erlyaws.github.io
BSD 3-Clause "New" or "Revised" License
1.28k stars 267 forks source link

randome/random. #278

Closed cmeiklejohn closed 8 years ago

capflam commented 8 years ago

Thanks @cmeiklejohn. I will merge it very soon.

vinoski commented 8 years ago

@capflam can verify but I think the randome spelling is intentional, to avoid a compilation warning under 19.0 due to warnings_as_errors being enabled. Changing randome to random causes this error:

compile: warnings being treated as errors
yaws_dynopts.erl:136: random:seed/3: the 'random' module is deprecated; use the 'rand' module instead
yaws_dynopts.erl:142: random:uniform/1: the 'random' module is deprecated; use the 'rand' module instead

The yaws_dynopts module replaces itself when Yaws starts, and the replacement source code (found in yaws_dynopts:source/0) is correct.

capflam commented 8 years ago

@vinoski, no, it is really a typo error. To avoid warnings on deprecated functions, in the default module, I use the fun keyword (e.g (fun random:uniform)(N) instead of random:uniform(N)). This is a trick to avoid compilation warning. It is important to have a valid default module because the generation during Yaws start could fail.

vinoski commented 8 years ago

@capflam: ah, ok, now I get it. Thanks for explaining it.

capflam commented 8 years ago

@cmeiklejohn, I've amended your fix and I've pushed it in master branch. Thanks !

cmeiklejohn commented 8 years ago

Wait, what's the fix to get around the compiler warnings?

cmeiklejohn commented 8 years ago

I'd like to apply it to this that we maintain for our work: https://github.com/lasp-lang/rand_compat

cmeiklejohn commented 8 years ago

Got it; thank you!