I don't know what to think. It's tricky.I can understand Stack Overflow's view concerning modifying/deleting existing posts, but I definitely also think that users should have the possibility to opt out, at least for posts made before the deal.
Dfa
type that stores a finite state machine. It must be normalized before being used by some other types; it's simply to make sure some properties are observed, like end states having IDs greater than non-end states and so on.General
and Normalized
.Dfa<General>
isn't normalized, and Dfa<Normalized>
is guaranteed to be. For example, I won't put any method that allows a modification in the normalized version that could un-normalize it, and you can only get a Dfa<Normalized>
from the methods that guarantee the proper requirements.pub struct General; // takes 0 bytes
pub struct Normalized; // takes 0 bytes
pub struct Dfa<T> {
... // it can be the same fields for both types or not
}
impl<T> Dfa<T> {
... // all the common methods go here
}
impl Dfa<General> {
// only way to create a Dfa object is through this:
pub fn new() -> Dfa<General> {
...
}
... // all the modifying methods go here
// only way to get a normalized type is throught this:
pub fn normalize(self) -> Dfa<Normalized> {
... // normalization process
}
}
Dfa<Normalized>
parameters. Still, I can use any method declared in the generic Dfa<T>
code, and any mistake like using modifying methods is detected at compile time.I think i'm going to disagree about python as a first language. Yes python is very powerful no so much because of the language but the available library (this was also true of basic many years ago); and yes python is more structured than basic so one could argue it is a more difficult but more structured first language. However python also has a lot of oops that simply shouldn't exist in a language intended to teach people how to program. My simple example:From a discussion on Codeproject (https://www.codeproject.com/Lounge.aspx?msg=6000758#xx6000758xx):
"I am currently listening to J.S. Bach - Brandenburg Concerto No. 2 in F major BWV 1047[^] on repeat while I program. Hearing those violins just sawing away, with that fun, occasional little four-note sequence (bah BAH bah bah..) makes my fingers just fly over the keyboard while I am programming!
According to an article by the NIH: Cognitive Crescendo: How Music Shapes the Brain’s Structure and Function - PMC[^] music stimulates the mind while working on intellectual tasks.
Anyone else have any favorite music they listen to make them write code at hyper speed?"
pibbuR who probably would listen to Motorpsycho, Magma or Dream Theater, UmmaGumma (first record) Never Jazz.
for x in range(7):
y = y + 1
y = y - 1
is different than
for x in range(7):
y = y + 1
y = y - 1
For me, this simple example would be in favour of Python, which has always been designed for clarity. Having a properly indented code is important to avoid misinterpreting it. Be sloppy with the indentation as the 2nd example and Python will yell at you (it's an error, so no risk of misinterpretation here).My simple example:
Here is where we disagree. I would not object if the code BOMBed; the interpreter said hey that line is neither in the for loop nor in the main 'loop'. And in that aspect i would agree with your thoughts as it is sloppy. However since the code is treated as correct but behaves differently this causes correctness issue in a large system. You shouldn't have a correctness issue due to this sort of error (imho).For me, this simple example would be in favour of Python, which has always been designed for clarity. Having a properly indented code is important to avoid misinterpreting it. Be sloppy with the indentation as the 2nd example and Python will yell at you (it's an error, so no risk of misinterpretation here).
That's what happens here: the interpreter stops and says the indentation is inconsistent. I don't see what more one could wish for. The code is not treated as correct.Here is where we disagree. I would not object if the code BOMBed; the interpreter said hey that line is neither in the for loop nor in the main 'loop'. And in that aspect i would agree with your thoughts as it is sloppy. However since the code is treated as correct but behaves differently this causes correctness issue in a large system. You shouldn't have a correctness issue due to this sort of error (imho).
Now it would be easy enough for the language to treat it as a fatal error as it should require that the indentation to be consistent at all level IF the indentation has semantic meaning (which it does). I see that as a sloppy defn in the language that makes it a bad candidate for large system.
At least that is my reasoning. Obviously you seem to feel differently and i guess that is fine even if i disagree.
Hey no fair; they changed the interpreter; the last time i used python it didn't flag the issue but ignored it.That's what happens here: the interpreter stops and says the indentation is inconsistent. I don't see what more one could wish for. The code is not treated as correct.
Besides, it's really the same as mixing up opening and closing brackets in languages like C or Rust. It happens all the time, but thankfully the compiler can usually detect it.
View attachment 5333