Comments (4)
Just a question in ignorance as I don't know the difference between the functions, but what's the reason to use love's math function as an override? Additionally, shouldn't that be an override you set outside of the lume library rather than expecting lume itself to be aware of another library being present?
from lume.
@jaythomas love.math.random
and love
in its entirety is meant to be cross-platform, whereas lua's math.random
can vary by platform. This can complicate situations where two games are sharing a random seed and generating information or making decisions side-by-side. @slime73 knows better than me, though.
from lume.
Thanks, @EntranceJew. That answers my first question.
The reason I asked the second question is because my concern is that by making it the library's responsibility to have an awareness of love's random function, you are introducing a bias towards using this library in conjunction with love. As a user of this library, I may be using lume inside a service where love is not defined globally, or perhaps I'm not using love at all. Personally, I think it makes more sense to implement a "mixin" function where you can register new functions or override existing top-level functions like math_random
. Psuedo code:
lume.mixin('math_random', love.math.random)
This way if I wanted to use a completely different random function, or if love decided to move the random function somewhere else, the library wouldn't care. Not its job to be responsible for other librarys' APIs.
Again, just my opinion.
from lume.
Agreeing with several for @jaythomas's points, mainly:
... my concern is that by making it the library's responsibility to have an awareness of love's random function, you are introducing a bias towards using this library in conjunction with love.
So I won't be including this, nor merging the corresponding pull request (#13).
That being said, I do like the idea of supporting a mechanism for the user to supply their own random()
function. I'm aware of the short comings of Lua's math.random()
, on Windows, for example, last time I checked its implementation of rand()
would return a 15bit integer which is at best not ideal.
I'll have to think about the best way to go about this (in terms of naming, and exactly how the provided random()
function is expected to act) before adding it in.
from lume.
Related Issues (20)
- Support writing functions/threads in lume.serialize HOT 2
- lume.array HOT 2
- hotswap discards non-table values HOT 2
- memorize not memoize HOT 1
- lume.sign(x) with 0 -> 0 ? HOT 2
- setTimeout() and setInterval() HOT 2
- Possibility of adding lume.deepclone
- lume.reduce with a falsy initial value HOT 1
- unable to install via luarocks with lua 5.4 HOT 1
- lume.format(str, table) doesn't properly handle false values HOT 3
- pass keys to lume.map function
- `lume.isarray` doesn't return correct results for mixed tables or empty arrays HOT 4
- Just some food for thought... math.round HOT 2
- Probabilities of `lume.shuffle` are horribly broken HOT 1
- lume.weightedchoice - if rnd <= v instead of if rnd < v
- Sort functions alphabetically HOT 1
- val^0.5 faster than math.sqrt(val)? HOT 1
- lume.sign(0) returns 1 rather than 0 HOT 3
- luacheck? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lume.