I haven't tried it and am afk rn but I'd imagine you just define a constexpr function that implements collatz and use that in your contract.
(Edit: if the input is constexpr itself)
Its also quire easy to think about specializing a few templates and doing it that way. If you look up an example of the fib sequence in c++ templates you'll get the general idea.
I feel like I'd have something to learn from seeing the code.
Won't you just run into a constexpr evaluation depth error with a suggestion to set -fconstexpr-depth? I don't see how this is the gotcha it's made out to be.
I'd exepct something like that to happen. Worth reiterating that the whole scenario is for a hypothetical different implementation of contract that would execute comptime, as noted in the parent thread.
If you wanted a c++26 preconditon for collatz tho, here it is.
```cpp
bool collatz(unsigned long long n) {
while (n != 1) n = n % 2 ? 3 * n + 1 : n / 2;
return true;
}
void f(unsigned long long n) pre(collatz(n));
```
That's basically what you'd write if you were doing it with asserts, as the linked article states, just now you add it to the declaration.
“ISO C language standard requires that C compilers support the following three pragmas, and some C++ compiler vendors support them, to varying degrees, in their C++ frontends:
At least some GCC devs claimed that the standard does not impose any requirements on these macros if a compiler does not claim strict ISO/IEC 6055 (aka IEE 754) conformance (which is still optional, and gcc and clang do not claim it).
A C implementation can be fully-compliant without conforming to ISO/IEC 6055, that's optional; question is just whether that optionality extends to fenv.h too. (at least how far I looked, imo it doesn't, and the pragma must exist, and valid fesetround calls (which there may be none of if no FE_* rounding modes are defined) must be represented by FLT_ROUNDS, even if it changes literally no actual float op behavior)
It's hard or maybe impossible to figure out what BB(10) is. But abstractly, it is some finite integer. That finite integer is trivially computable: make a turing machine that hardcodes all the digits and outputs them one by one. You can't know that this machine actually produces BB(10) if you don't know what BB(10) is, but that's separate from the question of whether the number itself is computable.
There is some notational subtletly here. Strictly speaking, BB(n) represents the output of the BB function for the input n. In that sense BB(n) is computable.
However, the BB function itself is not computable. It makes sense to ask "for what inputs is the BB function computable?". When people talk about BB(n) not being computable, they are really talking about the computability of the BB function at n, not the computability of the integer that happens to be BB(n).
BB(10) is computable. That doesn’t mean anyone can actually figure out what it is. It doesn’t even mean it’s theoretically possible to do so. Computable just means that there exists a turing machine that will output the digits.
> The implemented Rust semantics are not sound, as evidenced by this issue. We need to find (or adjust) sound semantics.
You’re ignoring the possibility that Rust semantics are sound, and the implementation doesn’t fully implement them. In that case, we do not have to find sound semantics.
That, I think, by far is the most likely option.
Reason: I’ve not seen a single comment claiming the example should compile, and zillions (implicitly) acknowledging this is not what Rust should do.
I explicitly did not ignore the option that there are possible sound semantics:
> but not necessarily for this one specifically
> Maybe, maybe not.
But "the Rust semantics" are not defined, formally. The closest we have is what Rust implements currently, and that was shown here to not be sound. Other than that, we maybe have vague ideas in the brains of some T-types members, which are not detailed enough to determine soundness (source: those type system people want to formalize the semantics so they will be).
And for the record, we know of other soundness issues where the likely resolution path will involve rejecting valid programs we accept now, and the only question is how many.
"the Rust semantics" are defined informally as sound. Anything that the implementation accepts that is unsound is a bug. We might never be able to prove the rust implementation, and may forever find loop holes, but informally it is sound and that is the intent.
> The original was dialled-in to be small (obviously), dignified, reserved, charming, practical.
I disagree. It was designed to be affordable (both in sales price and in maintenance) and practical. It only was small because that was needed to meet those goals. Reserved as in “no frills” also comes from “affordable”.
Dignified I don’t think it ever was. What do you think made it that?
> it would look something like a = round(fma(a, b, c))
One problem with that is that it makes it look as if the language is more expressive than it is. You might not be able to write, for example
d = round(fma(a, b, c))
because the instruction doing that is a three-register one.
Another example, on x64 (IIRC)
a = a + b + 42
d = d + 4 × e
d = 5 × d // equivalent to d = d + 4 × d
would be valid (being LEA variants), but
a = a + b + c
d = d + 5 × e
d = 7 × d
would not. So, this would be more readable, but I’m not sure it would be easier to write.
You can make it easier to write by allowing ‘obvious’ rewrites such as
a = b + c + d
into
a = b + c
a = a + d
but then, you’re on your way towards a generic programming language, and where do you stop?
It also soon doesn’t get obvious, as it might be possible to avoid the data dependency in the rewrite or to do another ‘obvious’ thing, and move the instruction following that a = a + d up between the two instructions.
I don't allow such rewrites, you have to be explicit. If you write something that doesn't have a valid assembler encoding, its rejected at compile time.
It helps that I'm currently targeting ARM (Cortex M33, RP2350 specifically). Old-school x86 would be much less pleasant, as it's got so many arbitrary-seeming rules of what works and what doesn't. One quirk, when optimizing for file size, are the rules for which instructions have 16 bit encodings and which need 32. But again, the plan is to have a tight feedback loop.
“Jolla has sold 15,000 units of its phone as of August 2026 just by taking pre-orders for production batches from its web site”
In comparison, Apple easily sells 15,000 phones each hour of the year.
So, the best hope for such a Linux phone would be to have something installable on hardware of a third party that normally ships Android. I don’t see that happen because such hardware gets locked down more and more to defend against cybercrime.
I don't think it is fair comparing Jolla agains half of the current Smartphone monopolists.
Also you need to build an ecosystem so that users and developers can get involved & open hardware fully supported by Sailfish OS is a good start.
Also a lot of mainstream mobile hardware is locked down on purpose to effectively enforce planned obsolescence, which makes it harder to port a sane OS on it.
“From 2019 to 2024, versions 1 to 4.3 (4.5 TV) of the operating system were built by integrating the Android Open Source Project (AOSP) with OpenHarmony, allowing it to support both HarmonyOS and Android apps. The current iteration of HarmonyOS became known as HarmonyOS NEXT (later it was renamed HarmonyOS 5 in launched of Pura X). HarmonyOS NEXT was announced on August 4, 2023, and officially launched on October 22, 2024. It also replaced the OpenHarmony multi-kernel system with its own HongMeng Kernel at its core and removed all Android code. Since version 5, HarmonyOS only supports apps in its native "App" format.
HarmonyOS 5.x+ both discards the common Unix-like Linux kernel and replaces the previous multiple-kernel, kernel agnostic system from OpenHarmony with its own bespoke HarmonyOS microkernel as a single framework.”
⇒ this shows it’s possible to create a new stack. It’s not Linux, though, and I think a large reason for this succeeding is that it started in the Chinese market after the US sanctioned Huawei.
> this shows it’s possible to create a new stack. It’s not Linux, though, and I think a large reason for this succeeding is that it started in the Chinese market after the US sanctioned Huawei.
Even so, I think it's helpful in that it weakens the duopoly. If app builders are getting used to building apps for other platforms than Android/iOS, it hopefully also becomes easier for others to gain some foothold.
Especially given the heavy commissions and other developer-hostile behaviour of these two. They've been essentially treating devs like shit and IMO a reckoning has been coming for a while now. Of course, you do have to meet the users where they are, at least up to a point.
Further fragmenting the user base into a third closed ecosystem is good because app builders have to build 3 versions so...now they'll be more willing to build a fourth version?
That logic doesn't follow. This is bad in all meaningful ways for open source.
reply