Giter VIP home page Giter VIP logo

Comments (4)

DanielGavin avatar DanielGavin commented on July 21, 2024 1

I have now switched it so the bitsets get aligned.

from ols.

leidegre avatar leidegre commented on July 21, 2024

Here's another repo

Foo :: struct {
	A:     string,
	BBB:   string,
	CCCCC: Bar,
	DD:    Baz,
	EEEE:  int,
}

Bar :: struct {
	A:   string,
	BBB: string,
}

Baz :: bit_set[BazFlag]
BazFlag :: enum {
	A,
	B,
	C,
}
main :: proc() {
	// aligned
	foo := Foo {
		A    = "foo",
		BBB  = "bar",
		EEEE = 42,
	}

	// unaligned
	bar := Foo {
		A = "foo",
		BBB = "bar",
		CCCCC = Bar{},
	}

	baz := Foo {
		A = "foo",
		BBB = "bar",
		DD = {},
	}
}

The alignment of consecutive assignments within the aggregate initializer changes to unaligned when there's a nested brace of some sort. Is this intentional or unwarranted?

from ols.

DanielGavin avatar DanielGavin commented on July 21, 2024

The aggregate initializer currently disables alignment, because I'm worried of having to align stuff like this:

baz := Foo {
	A = "foo",
	BBB = "bar",
	DD = {
             my_value = 123123,
        },
}

It's both quite hard to align this correctly. There could even more than just one nest of braces. But in your example there is no named assignments in the aggregate initializer, so it could be possible to have it align anyway for that case.

Making that exception probably helps for most cases where braces are used like:

rtv_desc := d3d12.DESCRIPTOR_HEAP_DESC {
  Type = .RTV,
  NumDescriptors = BACK_BUFFER_COUNT,
  Flags = {.SHADER_VISIBLE},
}

from ols.

leidegre avatar leidegre commented on July 21, 2024

Yeah, I think it should be consistent. Either align assignments or not but don't change the behavior.

I've done plenty of compiler work in my days and I could give this a shot.

from ols.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.