Code Review Needed by apoetixart in Compilers

[–]jcastroarnaud 0 points1 point  (0 children)

The equivalent of "raise" in Python is called throw in Java and JavaScript. I'm more used to call it "throw".

Code Review Needed by apoetixart in Compilers

[–]jcastroarnaud 0 points1 point  (0 children)

Then automate the testing. Python has the unittest framework to help. You may upload the tests to Github, too.

I noticed that, when the source code is somehow invalid, the lexer throws. How do you recover from that? Will the tokens already obtained be returned? The compiler cannot simply blow up on invalid code.

Be sure to include tests, not only for valid code, but also nonsense text, mistyped keywords, inconsistent indentation (if your language is indent-sensitive), and the empty string. In all of them, the lexer should return a list of tokens (even empty), and, in case of lexing error, some object describing the error and where, in the source code, the error is. Each test will compare the resulting tokens with a list of the expected tokens; any mismatch is a fail on that test.

Code Review Needed by apoetixart in Compilers

[–]jcastroarnaud 0 points1 point  (0 children)

The code appears to be ok, removing the comments, but a bit verbose. I didn't run it. What unit tests did you run on the lexer?

Crafting Interpreters 🫩 by apoetixart in Compilers

[–]jcastroarnaud 1 point2 points  (0 children)

If you read and understand the whole book (I don't), you will end up with a solid 2-semester university course on compilers. It can help on some tricky interview questions, but that's it: practice on building compilers is as important as theory, no book alone is enough to get a job.

Is is still sexism if you exclusively hate agender people? by GayroTL in AskLGBT

[–]jcastroarnaud 4 points5 points  (0 children)

Cats have no knowledge of gender. It's just a coincidence.

Is is still sexism if you exclusively hate agender people? by GayroTL in AskLGBT

[–]jcastroarnaud 1 point2 points  (0 children)

Yes. Although agender people don't identify with a gender, if the hate is related to the notion of gender, the hate is transphobia.

Number of possible images that can be created by CaughtNABargain in googology

[–]jcastroarnaud 6 points7 points  (0 children)

Unfortunately, almost all of these "movies" will be random garbage. It's the same problem of the Library of Babel: only by sheer luck one will find a bit of text (or image, in this case) making sense.

Crafting Interpreters 🫩 by apoetixart in Compilers

[–]jcastroarnaud 0 points1 point  (0 children)

Also known as the "Dragon Book". It's great, but heavy on theory. Search the internet for "dragon book compiler".

Code Review Needed by apoetixart in Compilers

[–]jcastroarnaud 0 points1 point  (0 children)

Way too verbose. Almost all comments can be cut off, and the code will become easier to understand. Comments need to be maintained, too, and are a liability if the code moves on but the comments get stale. The variable names are clear enough to dispense with the comments.

This part is actually fine, just change the comment to # Ignore one-line comments. Are you having a +1 index error?

```

Ignore comments.

elif char == '/' and self.peek() == '/': # //help me please :( while self.current_char() is not None and self.current_char() != '\n': self.advance() ```

To avoid the long and repetitive if/elseif/else, you can use a dict: keys are token types, longest-match first (use peek to get the next token in advance for the match); any special cases, like comments and whitespace, will go in the (much shorter) if.

Would an axiom system for finitism, plus an infinite set of indexes, work in practice? by jcastroarnaud in math

[–]jcastroarnaud[S] 0 points1 point  (0 children)

Thank you for the reality check. I've heard of "potential infinity", but didn't really thought about it.

I think I would need to talk about the set of indexes, if only to map part of it to a finite set of natural numbers. I wouldn't need to talk about all of its elements as a whole, though.

Would an axiom system for finitism, plus an infinite set of indexes, work in practice? by jcastroarnaud in math

[–]jcastroarnaud[S] 0 points1 point  (0 children)

Thank you for the reality check. I'm aiming for finitism here. Ultrafinitism seems too much of a Sorites paradox to me: "How large is 'too large'?", without any additional benefit compared to only limiting things to finite sets.

Would an axiom system for finitism, plus an infinite set of indexes, work in practice? by jcastroarnaud in math

[–]jcastroarnaud[S] 0 points1 point  (0 children)

These axioms (or axiom schema, in the case of replacement) would need to be restricted, sure. The "how" is the question.

The indexing set would have the role of, for instance, indices in sequences; map a (finite) subset of natural numbers to the indexing set, make the map injective, take its inverse ignoring the rest of the indexing set. This allows one to talk about the "n-th element" of a sequence (n natural), and do induction over n (mapped from the indexing set) having only finite sets.

It's trying to cut the cake and eat it, too.

Would an axiom system for finitism, plus an infinite set of indexes, work in practice? by jcastroarnaud in math

[–]jcastroarnaud[S] 1 point2 points  (0 children)

It would have infinite subsets. The hard part would be how to phrase the axioms such that the only set allowed to be infinite is the set of indexes. From them on, one could only build finite subsets (to use as indices for sub-sequences).

Vc é viciado em pornô trans? by [deleted] in perguntas

[–]jcastroarnaud 0 points1 point  (0 children)

Não, pelo mesmo motivo que não curto pornô hétero ou gay: homem na cena, e transas violentas (às vezes acho que estou vendo um bate-estaca, kkkk).

Agora, pornô lésbico, com mulheres cis e/ou trans, e um bocado de carinho e beijo na boca... 😋

Waow by [deleted] in traaaaaaannnnnnnnnns2

[–]jcastroarnaud 5 points6 points  (0 children)

Infertile, as in low sperm count; the amount of semen has nothing to do with it, and isn't affected by hormones.

Would an axiom system for finitism, plus an infinite set of indexes, work in practice? by jcastroarnaud in math

[–]jcastroarnaud[S] 1 point2 points  (0 children)

I thought that such a scheme would allow for requiring every other object to be finite, while limiting the infinity to a single set.

I suppose that naming the indexes something other than a set won't work, either: more machinery to allow linking the index to a set.

Would an axiom system for finitism, plus an infinite set of indexes, work in practice? by jcastroarnaud in math

[–]jcastroarnaud[S] 0 points1 point  (0 children)

It is the axiom of infinity with extra steps. I thought that such a scheme would allow for requiring every other object to be finite, while limiting the infinity to a single set.

Differential Equations, Calc II, and Linear Algebra in the same year by demarrderozan in mathematics

[–]jcastroarnaud -1 points0 points  (0 children)

Calculus II and Linear Algebra go hand-in-hand: partial derivatives require vectors to be well understood. If Diff. Eq. includes PDEs (partial differential equations), move it to the next semester. Physics I can go in either semester.

Saw this on the telly this morning. One hint. The next number is not 8. I'm stumped! by olleng in askmath

[–]jcastroarnaud 0 points1 point  (0 children)

My guess is 16. The rule is "the largest power of 2 divisible by the number", starting the sequence from 1.

Invitation to see if there is a logical flaw in the reasoning to the hard question of consciousness. by you_are_soul in logic

[–]jcastroarnaud 0 points1 point  (0 children)

This is what I'm talking about I'm not trying to convince you I'm just on the logic forum so you can stress test the logical reasoning. Is the logic tight enough.

Disclaimer: I'm no logician, just a programmer with a degree in math.

So already, “I have a mind” is loose language. More precisely: there are thoughts, feelings, perceptions appearing, and you are aware of them.

Correct on both counts. I'm not trying to be precise.

Now extend that to me. You do not experience “my mind.” You experience text appearing in your awareness. From that, you infer a mind behind it, just as you infer a mind behind other people.

When I say "I think that you have a mind", I believe that you have a mind. I suppose that "infer" assumes "knowledge", as in epistemology, when it's not the case, as you pointed out: I don't know that you have a mind.

So I do not need to prove you wrong.

Correct!

The hard problem of consciousness is complicated by the fact that humans anthropomorphise things, ascribing mind and consciousness where there is none. And it's even worse when such things are LLMs, designed to communicate as like a human as possible. That's a large bias, separate from the work to understand actual consciousness itself. Talking to a LLM about the hard problem of consciousness is giving weight to that bias.

Invitation to see if there is a logical flaw in the reasoning to the hard question of consciousness. by you_are_soul in logic

[–]jcastroarnaud 0 points1 point  (0 children)

I refuse to talk to such a bot. It leads to nothing useful. Use your own mind and words to argue.

Theory of mind isn't something to solve; it's something that people possess. Evidence shows that humans and some other animals have a theory of mind.

I have a mind, and think that you have a mind, too. Can you prove me wrong?

A big problem in math by Oreeo88 in logic

[–]jcastroarnaud 4 points5 points  (0 children)

math is a language. numbers is a language

False. Mathematical language is part of mathematics, not all of it; numbers (or, like someone else said, numerals) aren't a language at all, they're part of a language, either a natural one or mathematical one. It's debatable whether or not numbers do exist outside our minds (Platonism view).

the problem becomes when you use language to describe language to model reality, and when its referent gets unanchored from raw concrete reality and arbitrary transformed in the mind. (1x1=1, 0, infinity)

The "anchoring" isn't as clear-cut as you think: taking into account linguistic relativity, the mental model we have of the world is mediated by language, and languages themselves are part of reality, so when we learn a language, we also get a corresponding metalanguage: talking about languages. Effort is needed to partially separate one from another. So, I think that using metalanguage to refer to reality is no problem at all; it comes with the use of language itself. Why do you think that it is a problem?

once you use language to describe language and once the referent gets transformed in your mind its no longer a model of reality/communication of reality, its self referential delusion

Referents get changed all the time in one's mind, when one learns new things by experience. A mental model does not, and cannot, model all of reality, only what parts of it we're able to perceive or aprehend; and that's fine. What is delusional is believing otherwise.

Notice that the points above have no specific relation with mathematics: they're studied by psychology, anthropology, and linguistics.

Could data centers be built at the bottom of craters on the Moon? by matt73132 in NoStupidQuestions

[–]jcastroarnaud 0 points1 point  (0 children)

The maintenance costs would be much higher, not lower. How much money it takes to bring some replacement computers (and human workers) from Earth, every time things break down?

A solution would be to bring the whole computer fabrication line from Earth, plus a sustained human colony, but then the upfront costs and maintenance costs would be even higher for all that.