5 ms·
The proposed syntax is not intuitive... How can I know to which records x, y and z are refering to in: Point newLoc = oldLoc with { x = 2; y = 2; z *= 2; } ? An
by pulse7 3y ago
The proposed syntax is not intuitive... How can I know to which records x, y and z are refering to in: Point newLoc = oldLoc with { x = 2; y = 2; z *= 2; } ? And in this case "return this with { im = -im; };" - which "im" goes to which record? Please make more intuitive syntax for this!
- davidalayachew 3y agoThe general idea behind JEP Drafts such as these is that they first focus on the semantics -- what can/should this feature do? They save things like syntax until the very end, right before they decide to submit this as an actual JEP instead of a JEP Draft. This JEP entered the Draft stage only a few hours ago. All that is to say -- your comment makes sense, but you are criticizing the part of this JEP Draft that is not only the least relevant to the discussion, but the thing that is most likely to change before it exits the Draft stage. Oftentimes, they even put in placeholder syntax to highlight this fact. I'd limit criticisms of syntax until they submit this JEP for actual review.
- marwis 3y agoWell, records are immutable so assignment must go to newly constructed instance, meanwhile new instance does not exist yet so any read must be from old instance. Seems very intuitive to me (and same as C#).
- pulse7 3y agoIf it is intuitive one does not need an explanation...
- funcDropShadow 3y agoTherefore, everything you already know is intuitive. Oh wait, does that mean that intuitive is not a property of this proposal but of the reader and the proposal? Ergo, it is almost useless to ask whether some programming language feature is intuitive or not.