Skip to content

remove this #1283

Closed
Closed

Description

@andrewrk

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.

Activity

  1. added
    proposal
    on Jul 24, 2018
  2. added this to the 0.4.0 milestone on Jul 24, 2018
  3. thejoshwolfe commented on Jul 24, 2018

    @thejoshwolfe
    SponsorContributor

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

  4. andrewrk commented on Jul 24, 2018

    @andrewrk
    MemberAuthor

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

  5. added
    accepted
    on Sep 13, 2018
  6. added
    breaking
    on Sep 13, 2018
  7. modified the milestones: 0.4.0, 0.3.0 on Sep 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedbreakingproposal

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions