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 this #1283

Closed
andrewrk opened this issue Jul 24, 2018 · 2 comments
Closed

remove this #1283

andrewrk opened this issue Jul 24, 2018 · 2 comments
Labels
accepted This proposal is planned. breaking Implementing this issue could cause existing code to no longer compile or have different behavior. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone

Comments

@andrewrk
Copy link
Member

This feature was used for these things:

  • For structs which are created with comptime parameters to reference the type:
pub fn AlignedArrayList(comptime T: type, comptime A: u29) type {
    return struct {
        const Self = this;
...
  • For builtin functions to refer to a "scope" type:
[nix-shell:~/downloads/zig/build]$ grep -RI setFloatMode ../std/
../std/math/pow.zig:    @setFloatMode(this, @import("builtin").FloatMode.Strict);
../std/math/expm1.zig:    @setFloatMode(this, builtin.FloatMode.Strict);
../std/math/expm1.zig:    @setFloatMode(this, builtin.FloatMode.Strict);
../std/math/tan.zig:    @setFloatMode(this, @import("builtin").FloatMode.Strict);
../std/math/sinh.zig:    @setFloatMode(this, @import("builtin").FloatMode.Strict);
../std/math/ln.zig:    @setFloatMode(this, @import("builtin").FloatMode.Strict);
../std/math/ln.zig:    @setFloatMode(this, @import("builtin").FloatMode.Strict);
../std/math/complex/exp.zig:    @setFloatMode(this, @import("builtin").FloatMode.Strict);
../std/math/floor.zig:        @setFloatMode(this, builtin.FloatMode.Strict);
../std/math/floor.zig:        @setFloatMode(this, builtin.FloatMode.Strict);
../std/math/exp2.zig:    @setFloatMode(this, @import("builtin").FloatMode.Strict);
../std/math/exp2.zig:    @setFloatMode(this, @import("builtin").FloatMode.Strict);
../std/math/exp.zig:    @setFloatMode(this, builtin.FloatMode.Strict);
../std/math/exp.zig:    @setFloatMode(this, builtin.FloatMode.Strict);
../std/math/cos.zig:    @setFloatMode(this, @import("builtin").FloatMode.Strict);
../std/math/round.zig:        @setFloatMode(this, builtin.FloatMode.Strict);
../std/math/round.zig:        @setFloatMode(this, builtin.FloatMode.Strict);
../std/math/sin.zig:    @setFloatMode(this, @import("builtin").FloatMode.Strict);
../std/math/ceil.zig:        @setFloatMode(this, builtin.FloatMode.Strict);
../std/math/ceil.zig:        @setFloatMode(this, builtin.FloatMode.Strict);
../std/fmt/errol/index.zig:    @setFloatMode(this, @import("builtin").FloatMode.Strict);

Here's my proposal to replace these uses:

  • Provide builtin function for getting the current type: @ThisType() - searches up in scope until it finds a struct, union, enum, or error, and returns that type.
  • Remove the scope parameter from the builtin functions such as @setFloatMode. We were always passing this anyway.
@andrewrk andrewrk added the proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. label Jul 24, 2018
@andrewrk andrewrk added this to the 0.4.0 milestone Jul 24, 2018
@thejoshwolfe
Copy link
Contributor

I use this to refer to the top level scope also. Would @ThisType() give me the global namespace outside of any other type?

@andrewrk
Copy link
Member Author

With #1047 it certainly would. Probably even without that proposal, it would refer to the namespace as you said.

@andrewrk andrewrk added the accepted This proposal is planned. label Sep 13, 2018
andrewrk added a commit that referenced this issue Sep 13, 2018
also document that scopes inherit this value. See #367
See #1283
@andrewrk andrewrk added the breaking Implementing this issue could cause existing code to no longer compile or have different behavior. label Sep 13, 2018
@andrewrk andrewrk modified the milestones: 0.4.0, 0.3.0 Sep 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted This proposal is planned. breaking Implementing this issue could cause existing code to no longer compile or have different behavior. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Projects
None yet
Development

No branches or pull requests

2 participants