Gazprea 2026 changes#93
Conversation
|
In the Declarations section we have the two lines:
Would it be clearer to use optional notation?
This gets into the relatively rich set of rules where you can elide either the type or the initialization, but not both. |
|
Added issue 94 |
|
Historically, we have had problems with naming/categorizing errors. The problem manifests as 1000s of questions for the TAs of the form: what error should XXX generate? The root is because now that we check for errors as part of competitive testing, we check that the type of error raised is correct. This has unintended side effects because for errors that could have multiple classifications the type can depend on the order of the semantic analysis passes. A related problem is that we used to require the compiler to stop as soon as it found the first error. I have advocated for looser checking: as long as the compiler notes that there was an error on the correct line we pass the test. This also requires that the compiler must not stop after the first error is found, so that our checkers can grep on the line number to match programs with multiple errors. |
|
Should we allow nested structs? |
|
Should we relax the restriction that structs have two fields? Rust actually uses 0 element structs effectively, and in some sense a 1 field struct is like a typedef vs typealias. I think tuples should retain the minimum of two fields, and that structs can't contain tuples. |
|
Section 7.7 of Arrays - did we decide to allow tuples and structs to be array elements? For structs, I guess the array declaration would be: Arrays of tuples might be weird looking: |
|
7.7.1 Array Declaration - I think the declaration is missing the (optional) <qualifier> |
|
7.7.3 Operations, Concatenation b - it says types must be automatically promotable, but could we also allow casts? Indexing - Should have a LHS example of indexing. Should we also say anything about indices being l-values? |
|
7.7.4 Slices - it says slices can be strided using The example needs to be fixed - c has 10 elements but we only print 6, and 3rd example uses The section only talks about slices as parameters, but they can also be used in assignments and expressions: We haven't talked about the 3rd example before, but I believe it is consistent with slice semantics |
|
Section 7.8 Vectors - it may be possible that vectors and arrays are interchangeable because of slices. If that is true, then we may want to say something about it in the intro. In 7.8.1 we forgot 7.8.2 - we probably shouldn't lead with the erroneous slice example, especially since we haven't introduced vector methods yet. I also think the examples look suspicious, at least, to me they raise as many questions as they answer. |
|
7.10 Matrices - I think we should stop talking about the builtin 2D matrices as arrays of arrays. That definitely influences people away from dense matrices, which as you know, is the only true representation. (BTW, you can ask Nelson if nested vectors can be optimized - if they can I will drop my request). |
|
I have been thinking that operators like I don't know if this is a good idea, but I like it. I think it may be complex and non-rewarding to implement, however. |
Fixing this, I have a question: can vectors be type inferred? e.g. |
Imo, yes to all. Ayrton says:
I have ideas of optimizations students can do with a gazprea MLIR dialect that depend on nested types. FWIW, I am relatively certain that the gazprea MLIR backend I wrote in 415 was capable of arbitrary nesting of aggregate types. |
I think you nailed it: super cool but extremely hard to implement. A simple slice can be implemented with: This is (almost) exactly what both an array and a vector look like. The key is their The trick is that you have to go from sparse to dense so you can apply the operators normally. Note that all your operators would have to be rewritten to work with the extra level of indirection. |
Great question! I think there are arguments to go either way, but I would lean towards |
Do you think we can make our reference solution handle nested aggregate types? Do you think we still have need of a reference solution? |
|
Definitely possible to make a reference solution with nested structs, but I am no longer sure that we need a reference solution personally, I think we will have a clearer idea of how we are going to evaluate the students after our meeting next week. In terms of the by operator, I think we should drop it because of what you guys discussed above. I think that the single allocation for matrices is important for all static arrays, and that we can make all static-sized arrays (n-d) one contiguous memory allocation. We should note this to the students when we discuss how to implement dynamic arrays. |
Just a place to have a discussion. I already opened #92
and #91