http://d.puremagic.com/issues/show_bug.cgi?id=11206
--- Comment #3 from Maxim Fomin <[email protected]> 2013-10-09 09:38:00 PDT --- (In reply to comment #2) > (In reply to comment #1) > > So, what? > > > > Basically you are complainig about: > > > > import std.stdio; > > > > struct AGG > > { > > int[1] t; > > double d; > > } > > > > void main() > > { > > AGG tarr2 = AGG(1); > > writeln(tarr2); > > } > > > > which prints AGG([1], nan). > > ...Unsure what you are trying to show? the "AGG(1)". actually the AGG([1], nan) to show struct literal behavior. > > AGG(1) is a struct literal which is valid in D. > > I'm arguing that AGG should not be constructible taking a 1. That's clear, but if you want to break the language you need to consider writing to newsgroup. Silent language change based on some issue in bugzilla is evil. > > Integer literal is a valid > > initializer for static array. Statement "AGG!S ts1 = AGG!S(1);" is rejected > > because (unfortunately) 1 is not convertible to struct. > > Yes, integer is a valid initializer for a static array, and it is also a valid > initializer for a struct that holds an int. Right. > > However, 1 is not convertible to a struct, Right. It is sad fact but in this context it is irrelevant because in the example there is no conversion from 1 to struct, there is struct literal with partial initializer which match initializer for first field. > not is it convertible to a static array. Wrong. int[1] ai = 1; ai = 1; is fine with the language so far. However in this case we speak about struct initializer so having integer literal to be initializer for static integer array is sufficient. > AGG(1) should not compile, because 1 is not convertible to > typeof(AGG.tupleof[0]); Please refer to the spec or argue if spec is incomplete for a particular case. Making up rules is not good. Adressing your point - this is incorrect because typeof(AGG.tupleof[0]) has type int[1] and initializaing or assigning 1 to int[1] is legal in D. I deliberatly unwrapped all templates to show that you are effectivelly protesting against int[1] = 1; > What's happening is an implicit *construction* of a static array, in a context > where implicit construction is not allowed. This is not the case. Here is struct literal with partial list of initializers which match respective type initializers which is fine as far D is concern. If you are complaining because this breaks some assumption of a brilliant phobos ideom, this should be mentioned explicitly so some solution without damaging language can be found (personally I object to break the language for the sake of writing cute template in phobos). Please don't reopen issue: CLOSED->REOPENED->CLOSED war is not good either. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
