-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vmod_std: Add std.pow #4001
base: master
Are you sure you want to change the base?
vmod_std: Add std.pow #4001
Conversation
I am not against, but my question is: Do we really want to continue adding functions piecemeal or should we try to get something like libm covered as a whole? |
I can add more functions, but I don't think it makes sense to add all of them. So, what about a list of functions that are most valuable? And I'll have some time next week to add them. |
I can not provide a list of "most valuable" functions. You need a function when you need it. Standard libraries provide functions which were deemed valuable before we knew they were, which is why I am asking if we should go for full coverage. Because we do not have complex numbers in VCL, I think this could be a starting point: https://sourceware.org/newlib/libm.html#Math an |
I would prefer to have a separate VMOD for Starting off with a few functions makes sense to me, for example,
but adding many should be very simple, too. IMHO, the VMOD Furthermore, I think that also For |
I agree, this would mimic more or less what Python 3 has: https://docs.python.org/3/library/math.html |
bugwash is asking for examples of use cases |
I do not feel any of this clears Gettys' first law: »Do not add new functionality unless an implementor cannot complete Convince me... |
@fwsGonzo and me discussed this a while ago, and we agreed that maybe an open source VMOD |
@hermunn closing this issue without some initial movement on the math module would hide any potential need for this raised here. My use-case is quite trivial: exponential rate-limiting for IPs with data stored in Redis, that's used like so:
An alternative was to use built-in support for
|
Interesting. Without any information on the background at all, I did wildly guess during bugwash:
Some library functions are so fundamental, that I think we should just make them available fully:
|
During bugwash I suggested borrowing the -db.push(std.real2integer(120.0 * std.pow(2.0, std.real(req.http.seen, 1.0) - 1.0), 1));
+db.push(std.real2integer(120.0 * (2.0 ** (std.real(req.http.seen, 1.0) - 1.0)), 1)); But only slightly it would seem. |
This adds
std.pow
.Question: Link against libm?