M2 icon indicating copy to clipboard operation
M2 copied to clipboard

new Minus

Open DanGrayson opened this issue 1 year ago • 3 comments

i6 : new Minus from {a,b,c}

o6 = -a

o6 : Expression of class Minus

An error message should be issued here, because the initializing list has length greater than 1.

DanGrayson avatar May 18 '24 21:05 DanGrayson

Or should net(Minus) be updated to return -{a,b,c} instead?

d-torrance avatar May 18 '24 23:05 d-torrance

No,net works correctly, a Minus is supposed to be of length 1. That being said I don't understand the original issue. There are plenty of "illegal" objects one can create using the "new" construction. The latter is low level and therefore allows (and should allow) to construct essentially anything. For a given class, one can always create a high level constructor (e.g., hashTable for HashTable) that can do all kinds of checks as needed.

pzinn avatar May 19 '24 01:05 pzinn

i1 : new GradedModule from { blah => foo }

o1 = 0

o1 : GradedModule

i2 : peek oo

o2 = GradedModule{blah => foo}

mahrud avatar May 19 '24 03:05 mahrud