qtxie on master
Revert "FIX: simple fix `reques… (compare)
dockimbel on master
FIX: issue #4969 (Copy of error… (compare)
dockimbel on master
FIX: [R/S][ARM] compiler was cr… (compare)
1,234
rather than 1,000,000
? Moreover, why should we insist on localizing the decimal separator, if we don't localize everything else?The number type represents real (double-precision floating-point) numbers. Lua has no integer type, as it does not need it. There is a widespread misconception about floating-point arithmetic errors and some people fear that even a simple increment can go weird with floating-point numbers. The fact is that, when you use a double to represent an integer, there is no rounding error at all (unless the number is greater than 100,000,000,000,000). Specifically, a Lua number can represent any long integer without rounding problems. Moreover, most modern CPUs do floating-point arithmetic as fast as (or even faster than) integer arithmetic.
@dockimbel agreed on your points, er, comments. I believe you proposed point!
as the name initially, which I thought was fine, but coordinate!
is much more specific and perhaps better, even if longer. Other domain uses of point
may not be common, but there can really be no confusion about coordinate!
Did your original syntax proposal use parens around the numbers? e.g. (1.0, 2.0, 3.0)
My gut instinct prefers that over a non-spaced comma connector sigil. It's also a direct mapping of mathematical notation.
I'm in the U.S., so can't have an unbiased perspective on commas. I think the original intent was good on Carl's part, but I don't know that it has been a practical benefit.
pair!
with float32!
- I always thought that pair!
will be casted to float!
when one of its components overflows, the way it does with integer!
and float!
, and that float-based pair will be created with <float>x<float>
; point!
with optional 3rd component makes sense, and common notation for that is (x, y, z)
. But I'd prefer pair!
and point!
to be merged together, if possible, as it's just an implementation detail and discrete vs. continuous difference, which IMO shouldn't be user-facing.load
able lexical forms (this parallels recent discussion about JSON codec and messy external data); there's no substantial gain from ditching it... but then it makes (x, y, z)
point!
literal form a bit ambiguous.point!
in VID, Draw and View, and how to interpret its 3rd component (we're talking about 2D interfaces and images here). I also recall some ad-hoc point!
struct being used in Parse, to track internal state.
(x, y, z)
form, I suppose ,
becomes a word delimiter (like brackets), then both (x,y,z)
and (x , y , z)
are also valid? How will this form live along the paren!
and compose
is what I'm concerned with. Will comma become as sort of a composition operator that concatenates numbers into a point!
? May then words and expressions be used instead of numbers in place of x
y
and z
?
Will comma become as sort of a composition operator that concatenates numbers into a point!?
In such case parens are not strictly required and we end up with
object!
or function!
) and require evaluation to be createdpoint!
constructor?) on the level of APL family, which is limited solely to point!
valuesMay then words and expressions be used instead of numbers in place of x y and z?
That's a more general question WRT support of symbols in aggregate values, e.g. use r.g.b
in tuple!
or quantity%
in percent!
(BTW, does axb
pair!
smells fishy to you?).
point!
is more like a struct, and the vector!
is more like a constrained block!
:point_up: September 24, 2019 1:56 PM Interesting questions @hiiamboris. If we think of point!
like pair!
, then no. They are strictly numeric in literal form. But if we think of them like parens, compose/reduce
should work just fine. Effectively, the commas are there only to identify the literal form and are invisible otherwise. So the lexer can still identify them. Boy, it's a can of worms though, isn't it? It also forces the comma-as-decimal issue.
My gut says no to a non-paren, comma-connected syntax. But I'll have to think about it more, and try to overcome my history. What is the value in supporting it, I wonder?
My original thought, long ago, was simply to extend pair syntax to allow a third, optional segment. The argument, which we face even now, is that floats are harder to read in that context. But let's think about that, along with how literal coordinate!
values would likely be written. Will we use them with placeholder words, to be composed? What are the use cases for entirely literal coordinate!
values? Integer pairs, and their primary use(s) are easy. Pixels in UIs with VID and image sizes. What other literal pair values do people use? Anyone?
Can we identify the primary use cases for literal coordinate!
values? Chime in people. Some math cases, certainly, and possibly some multipliers in 3D systems.
After literal forms that humans write, we have stored/exchanged values, which humans may see, but don't deal with too much, except in debugging. Then there are those values we never, ever see. We care about 1. We don't care about 3. 2 seems not so important to me in my current mood. Given that, I'm not likely to write floats out to a lot of decimal places by hand anyway, so the harm seems minimal when it comes to readability. That's true for either pair or paren syntax.
If that all makes sense, the value of paren syntax is being closer to mathematical notation. That's big. Is it big enough to warrant a completely separate syntax from pairs, which live in a similar domain for some uses? That's a really tough call.
float32-pair
should be fine. Every integer between -16777217 and 16777217 has an exact floating-point representation. For the use case of the integer-pair
, this is quite enough. That means we can process an image size up to 16777217x16777217 pixels without problem. We can use pair in a textarea which has up to 16777217 columns and 16777217 rows.
Some half-baked musings:
I think conformance to mathematical notation is not too important. There are plethora of expressions and constructs in programming languages for which there are specific mathematical notations that are too cumbersome to support lexically in a PL. Think e.g. of powers and roots. Type-ability, readability and Redfitness (conformity to Red-ways) are more important.
When it is easy to support it is advantageous of cause to have lexical form which is already established in mathematics (in some variation). In case of (1.0, 2.34, 3.01234)
it is easy to type and read, but 1.0x2.34x3.01234
is not too bad also, albeit a bit harder to read. But the parens/comma version brings confusion with paren evaluation mentioned above. E.g. compose [a (b) (1.0, 2.34, 3.14)]
. It's probably mainly psychological confusion as lexer can presumably easily recognize it as a special type. But visually, it's in parens but not a paren!
.
Can other forms be considered, e.g. x(1.0 2.34 30.1234)
? But it seems even harder to read, unless longer spaces are used: x(1.0 2.34 30.1234)
.
If with three members, it is certainly not a pair!
anymore. To be semantically precise it is more of a point
than coordinate
. According to MW (geometric) point
is "a geometric element that has zero dimensions and a location determinable by an ordered set of coordinates". Coordinates are values characterising the location of a point in different dimensions. Nitpicking, coordinates determine the location or position of a point. So may-be loc!
or pos!
? But then again, it depends on interpretation, these values can also characterize not position of a point but dimensions of an object. E.g. (3, 10, 5)
may be dimensions of an ellipsod, not a point or position. Thus, to leave room for different interpretations, it should rather be triple!
analogously to pair!
. But (sorry!) then it can't have just two members (as it was proposed to have two or three members). (It is probably pointless to point out that out of geometry "point" is not particularily pointed term. Did I make my point?)
What usage might this point!/loc!/coord!
(let it be point!
for now) have besides "coordinates of the position of a point"? Complex numbers and quaternions (and tessarines and bicomplex numbers) pop into mind. Two-member point!
might be interpreted as a complex number, quaternion might be presented as a block of float!
and 3-member point!
.
If pair!
can include float!
members as @qtxie points out above, then it seems very Redfit to have "floating" triplet!
s like 1.1x2.2x3.0
or 1x2x3
too.
Good thoughts. Thanks for weighing in @toomasv. Even for the puns. :^)
3) seems like a bad path to head down.
5) leads to more thoughts, like aliasing. But this is also a slippery slope. With Red you really have to know the context to give something meaning, but the ability to alias types could enforce more strictness. I tend to lean toward pushing that enforcement up into dialects and modules, but there are arguments to be made both ways.
I like the idea of triple!
, as it is domain non-specific, but it also has a very different connotation in the RDF domain. We already have that problem with tuple in other langs and such, so it's not a big problem IMO.