Skip to content
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

remove @maxValue and @minValue #1466

Closed
andrewrk opened this Issue Sep 4, 2018 · 5 comments

Comments

Projects
None yet
5 participants
@andrewrk
Copy link
Member

andrewrk commented Sep 4, 2018

Since they can be implemented easily in userland.

@andrewrk andrewrk added the proposal label Sep 4, 2018

@andrewrk andrewrk added this to the 0.4.0 milestone Sep 4, 2018

@bheads

This comment has been minimized.

Copy link

bheads commented Sep 4, 2018

What about supporting .min and .max ?

@thejoshwolfe

This comment has been minimized.

Copy link
Member

thejoshwolfe commented Sep 4, 2018

I recommend adding userland implementations in the std library. This usecase is common enough that there should be one obvious implementation for you to use.

I agree that builtin functions are unnecessary. keep the language small.

.min and .max is not the right api. That would make it tightly integrated into the language. something more like @import("srd").math.max(u32) would be better.

@kristate

This comment has been minimized.

Copy link
Contributor

kristate commented Sep 5, 2018

hmm, we already have min and max in std.math[0][1]. std.math.maxValue sounds good through.

[0] std.math.min

pub fn min(x: var, y: var) @typeOf(x + y) {
    return if (x < y) x else y;
}

test "math.min" {
    assert(min(i32(-1), i32(2)) == -1);
}

[1] std.math.max

pub fn max(x: var, y: var) @typeOf(x + y) {
    return if (x > y) x else y;
}

test "math.max" {
    assert(max(i32(-1), i32(2)) == 2);
}
@tgschultz

This comment has been minimized.

Copy link
Contributor

tgschultz commented Sep 5, 2018

I think it should really be in TypeInfo under the hood, which would mean that the maxValue and minValue functions should be in meta.

kristate added a commit to kristate/zig that referenced this issue Sep 5, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 5, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 5, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 5, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 5, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 5, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 5, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 5, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 6, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 6, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 6, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 6, 2018

@kristate

This comment has been minimized.

Copy link
Contributor

kristate commented Sep 6, 2018

Please add breaking tag.

kristate added a commit to kristate/zig that referenced this issue Sep 6, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 6, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 6, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 13, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 13, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 13, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 13, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 13, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 13, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 13, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 13, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 13, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 13, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 13, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 13, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 13, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 13, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 13, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 13, 2018

kristate added a commit to kristate/zig that referenced this issue Sep 13, 2018

@andrewrk andrewrk modified the milestones: 0.4.0, 0.5.0 Sep 28, 2018

kristate added a commit to kristate/zig that referenced this issue Oct 10, 2018

kristate added a commit to kristate/zig that referenced this issue Oct 10, 2018

kristate added a commit to kristate/zig that referenced this issue Oct 10, 2018

kristate added a commit to kristate/zig that referenced this issue Oct 10, 2018

kristate added a commit to kristate/zig that referenced this issue Oct 10, 2018

kristate added a commit to kristate/zig that referenced this issue Oct 10, 2018

@andrewrk andrewrk closed this in 2b395d4 Oct 26, 2018

@andrewrk andrewrk modified the milestones: 0.5.0, 0.4.0 Apr 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.