Hi Rowan, > Again, that only seems related to objects because that's what you're used to > in PHP, and even then you're overlooking an obvious exception: array(1, 2)
Arrays are a bad example here because their contents are themselves values. For example, it would make sense as an example if the third value in the array was a flag that controlled the mode in which array_merge operates, but in reality it is not. > If we ever do want to make decimals a native type, we would need some way to > initialise a decimal value, since 1.2 will initialise a float. One of the > most obvious options is a function-like syntax, decimal(1.2). If we do want > numbers to carry extra information in each value, it will be no problem at > all to support that. I don't see any point in "scalar types" that feel almost like objects, because it just feels like you're manipulating objects with procedural functions. Why not just use objects instead? > On the other side, just because something's easy doesn't mean it's the right > solution. We could make an object which contained a number and an operation, > and write this: > > $a = new NumberOp(42, 'add'); > $b = $a->exec(15); > $c = $b->withOperation('mul'); > $d = $c->exec(2); > > I'm sure you'd agree that would be a bad design. Yeah, I agree that this is a terrible example. But it's easy to come up with terrible examples like this. Shouldn't you use the original decimal class as an example for comparison? > So, again, I urge you to forget about it being easy to stick an extra > property on an object, and think in the abstract: does it make sense to say > "this number has a preferred rounding mode", rather than "this operation has > a preferred rounding mode". Sorry, but I have no idea what you mean by "numbers have rounding modes". Numbers are just numbers, and if there's something other than numbers in there, then to me it's an object. As you can see from the discussion so far, my idea of what a native type is and your idea of what a native type is are probably different. At least between the two of us, we may need to first have a discussion about what the native type should be. Regards. Saki