Then you have to join it all back together.
But none of this steals from your code speed, because it is all typechecking code. So you end up with safe array access that requires no runtime bounds checking!
Then you have to join it all back together.
But none of this steals from your code speed, because it is all typechecking code. So you end up with safe array access that requires no runtime bounds checking!
How about if we make fundamental syntactic operations on arrays be splitting and joining?
We can also make assignment and evaluation be entry-wise in the manner of Fortran and Matlab, rather than require it be reduced to a proper variable as in ATS. This way we still avoid the aliasing problem.
For example, if we do a quicksort, the two parts of the array are still fed separately to the two parts of the algorithm. Neither subprogram call can touch the other subprogram callās subarray.
Mind you, this requires that splitting an array CONSUME the original array, and that the array must be rejoined if it is to be recovered.
We do not have to enforce linear typing, only that splitting and joining be destructive operations.
But thatās just control of your symbol tables and such. Thatās just more syntax. You could probably even go full linear through syntax.
It likely does mean you arenāt going to be happy with the classic āorthogonalā syntax example, if it should appear as an initialization:
(if b then x else y fi) := 3
Still, if assignment to an initialized variable implies consumption of the previous value, then it is okay if not an initialization.
Oh, letās write that in Dijkstraās nondeterministic if-fi:
(if b => x | ~b => y fi) := 3
because let us say we want to use that, if only to introduce a new generation of programmers to it.
The big difference here is there is no sequence of operations. The code takes any one of the branches in the if-fi, it is not specified. The only thing that decides which branch is actually taken is the guard.
(I read stuff here in the Fediverse that makes me think, āThese people have no idea what ānondeterminismā and ādeterminismā even meanā.)
Of course the compiler could have decided ~b is the negation of b and so produced the same code as āif x then x else y fiā. But that is for the compiler writer to decide.
Meanwhile, the programmer actually has a simpler situation with which to do proofs. To do proofs with the earlier, non-Dijkstra formulation, one first usually throws away part of the information and mentally transforms to the Dijkstra formulation.
Also, suppose I left out the ~b guard. Then there would be no specified operation for if b were false. There is no fallthrough. The program is erroneous and presumably will terminate with an error message.
The program would have been erroneous in this case, anyway, because you cannot assign to ānothingā. But the principle is more general.
Absence of a guard is a common cause of nondeterminism in the Mercury language, though in Mercury I think guards are gone through in sequence.
Obviously, if the guards cover all the cases and are mutually exclusive, then the program is ACTUALLY deterministic. And a compiler may be able to confirm this.
As indeed a Mercury compiler has to be able to do, for the Mercury language, though there I believe the cases do not have to be mutually exclusive. In oneās mind, one assumes earlier tests that pass are actually excluded from later tests, and does proofs by using the Dijkstra formulation.
I am merely trying to make an āorthogonalā language. I can let the program terminate with an error if there is a case left out. At least I need not REQUIRE that a program be deterministic. In fact I think it silly to REQUIRE that a program be deterministic, and most programming languages in fact do not require this.
Indeed, they are happy to let you have, for instance, a loop despite that one has failed to prove it either terminating or nonterminating.
ATS, incidentally, has but one method for proving a recursion or loop terminating, which is ātermination metricsā. It involves having a typechecking variable, or a tuple of typechecking variables, move progressively towards zero without passing zero, on each iteration of the recursion or loop. It is mathematical induction mapped to counting backwards, although the counting can be by leaps and bounds (division, for instance).
ATS2 has both recursions and loops. Loops are poorly documented, thoā.
The following occurs to me:
If you start with bytes as the basic type, you can make EVERY type in the language be an array. And that includes records. For accessing a record is merely splitting of an array.
And a multidimensional array is also merely splitting of an array. This is already how it is done in Fortran. Indeed, in Fortran you can change the shape of an array simply by calling a subprogram that refers to the array differently.
In ATS things CAN be done this way in typechecking.
To some degree they are. The sizes of types and of objects are always measured in bytes. So you need to essentially treat each type as if it were an array of bytes. And you can actually make it so for typechecking, but it is a LINEAR cast, and so you must use ONLY that type until you convert it back to the original.
So it would be with our SYNTAX system. You can use only one SYNTAX at a time.
That would be different from Algol 68, I am sure. So we start with an array of 8 bytes...
And it has to be aligned on a proper boundary. Your x86 programmers forget about that! It has to be aligned on a proper boundary.
But we will merge the 8-array of BYTE into a 1-array of LONG REAL (or some such name). And that (as it really can in C) can be shorthanded as just a variable of LONG REAL. (*p and p[0] mean the same thing in C.)
A few little details that might be unusual.
Maybe we donāt use the usual āindexing by default starts at 1 (or 0) but you can change that.ā Maybe instead we just use ICON INDEXING.
This goes from 1 to n+1, with an equivalent scale from -n to 0. You would not believe how useful this is.
OTOH maybe one could say that what you devise has an equivalent scale of the kind.
Thus if you say there is a 0 to n scale, then you automatically also get -n-1 to -1. But this will not behave as Python people expect. -1 will mean ONE PAST THE END, not the last entry.
Well, so be it.
Another possibility, of course, is implicitly using modular types for indices. This might not be desirable, especially as for Fortran subprograms you often actually specify the modulus, or rather the stride for multiple dimensions. The compiler for my language might have disagreed with what you needed for Fortran.
In Fortran really all arrays are just vectors and the compiler has support for accessing them with arbitrary column major strides.
C programmers are used to row major but I think column major is perhaps very slightly better in some tiny way that obviously is unimportant and so we should forget about it.
Ada can do it either way but defaults to row major. I believe. I havenāt used arrays in Ada much.
@troi I always presumed it was row major in C simply because the notation made it look like a multidimensional array was an array of arrays. In D it actually does MEAN that, in general! Same in some assembly languages, no doubt, but my experience is mostly little Z80.
Otherwise it is mostly immaterial. In Fortran or Ada there is no notational reason.
The tiny advantage of column major might be that it keeps the data of matrix columns close together. Columns usually matter more than rows do.
@troi D has C matrices, which are really just vectors with a stride-based āviewā. But the default matrices in D are heap-allocated vectors of heap-allocated vectors. So it really is vectors of vectors.
I forget what such a matrix is called. I used to think it was called a dope vector, but thatās actually something else.
@troi C is very much, and on purpose, like assembly language programming. It was of course a substitute for using PDP-11 assembly language, in its early main use.
(On the PRIME they used FORTRAN in a similar way! Which I can understand, because I used FORTRAN for minor systems programming on the TRS-80. Older versions and standards of Fortran let you get at the system in practically any old way. About the only thing missing is a stack for recursion! Which can be added as an extension.)
@troi C sucked. It is just starting to be usable with C23. It still needs nested functions, for instance. GNU C has nested functions but they suck. Fortran has better nested subprograms than GNU C does, if what I have read is true.
Also I do not know why everyone things they have to use trampolines. GNAT does not use trampolines. ATS does not use trampolines for nested functions, and they nest without end, form closures, and compile to C. Thatās right, they form closures.
@chemoelectric For reasons I attribute to terminology I never got into segment register addressing used in the 16 bit Intel. It should have been dead simple for someone who mastered the mainframe base-and-displacement addressing. Many years later I tried to get into the X86-64 assembly but I just don't like Intel. Big effing code museums on a chip that they can't keep track of anymore.
In my limited experience with ARM assembly I find it almost beautiful.
@troi If I try to use the terminology of lifespans, the people who are technically trained in that stuff will choose either to be polite or to be assholes and they usually choose to be the latter. So I will not even BOTHER to try to come up with a technical term! It does not matter. Whatever estimate they come up with is WRONG. It is usually based on conventional statistics, which is just a bunch of hooey.
Truly, the field of statistics is a bunch of ad hoc hooey that actually means nothing.
@troi I was at Cape Canaveral as a 14-year-old there with tickets to still-under-construction-WaltDWorld given freebie to my family via my great uncle who had gotten them from someone, and saw not Voyager but Viking II on the pad a few days before its launch. But in those days I am sure they were using RCA CMOS chips for a lot of the electronics. Not just the microprocessors but the gate chips as well.
Milspec chips packaged in a ceramic sandwich that looked like a Hydrox cookie.
@troi I just turned on the Artemis mission. Iām against it, though. No reason to send people outside the van Allen belt if you have no scientific research in mind that cannot be done by a machine.
An idiot congressman just called them up at the capsule. Iām going to turn it off and switch to Monty Python reruns.
@chemoelectric Lose a day, try to catch up the next. I can't wait until my recovery smooths out and there's less deviation in my abilities from day to day. Sigh.
I understand your position re Artemis but we are not operating in a vacuum (no space humor intended). We've given up on symbolism, and China embraces it. I'm of the school of thought that says that we've only got one planet, we're destroying it, so we better learn to treat it better -or- colonize others and hope those colonies do better.
As flawed as Western Civilization is, I'd much rather we led the way than China. Russia has joined the US in abandonment of great goals for short term profit.
As the current regime in DC keeps gutting any government program where science and facts matter, I think China's got this "race" won.
https://www.dailynews.com/2012/04/22/charles-krauthammer-shuttles-end-a-symbol-of-us-decline/

AS the space shuttle Discovery flew three times around Washington, a final salute before landing at Dulles airport for retirement in a museum, thousands on the ground gazed upward with marvel and pride. Yet what they were witnessing, forā¦
@troi There is no possibility of colonizing other planets. It is simply a fact that humans cannot survive healthily anywhere but on Earth. The closest thing would be a wheel space station doing 1g.
But the main thing is that one should NEVER EVER EVER confuse the CATEGORY TERM āHUMANā for a living, breathing human being! This is the category error of the reprehensible āMars colonistsā. It does not matter one bit if āHumanity (a mere WORD!) survivesā.
What matters is INDIVIDUALS!
@troi I am glad, though, that it has been shown everyone and their grandmother knows how to do rockets better than Elon Musk does.
I mean, this mission was really just a combination of the Space Shuttle and Apollo. It was all old hat. And it didnāt blow up, like every one of Muskās Doom Freighters.
@troi I mean, seriously, the whole plot is dumb, and no one would actually have survived, which is why I can say this.
But there was really nothing gained. Who cares if there is āA new human race?ā Billions died. And these scum couldnāt even shed a tear. They had nothing but contempt for the dead.
@troi All of this is going to be canceled, anyway. The only reason they went through with this mission was probably Sunk Cost Fallacy.
The plans have been that the next mission would be on Muskās decrepit Doom Freighter rather than the SLS.
If all this had been serious, Obama wouldnāt have canceled that earlier project, whatever it was called. Constellation, I think. The one that only Orion survives from.