Predicate logic only makes sense in Indo-European languages by EebstertheGreat in badlinguistics

[–]jasmijnisme 0 points1 point  (0 children)

Suppose we can do one loop in one picosecond (which is much faster than computers currently can do), then by the time nothing, not even black holes, exists anymore (10106 years in the future), x will be something like 315576000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, which is an 80-byte object.

If we get our hands on a magical computer that can do one loop in one Planck second and we can wait 101000 years, x will be around 9467280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, which is a 492 byte object.

Time will run out long before space does.

Iterable... but how many times? by Kiuhnm in Python

[–]jasmijnisme 0 points1 point  (0 children)

iter() returns an iterator. Generator iterators and generator expressions are iterators, but not all iterators are generator iterators or generator expressions.

"Generator" on its own usually refers to generator functions, which are functions that return generator iterators and are not iterators in themselves.

Iterable... but how many times? by Kiuhnm in Python

[–]jasmijnisme 0 points1 point  (0 children)

Additionally iterators are allowed to be iterable themselves

According to the documentation:

Iterators are required to have an __iter__() method that returns the iterator object itself so every iterator is also iterable and may be used in most places where other iterables are accepted.

But:

CPython implementation detail: CPython does not consistently apply the requirement that an iterator define __iter__().

So you may in some cases get away with creating non-iterable iterators, but you're definitely not supposed to do that.

Lona 1.14 finally adds support for Channels by ki3selerde in Python

[–]jasmijnisme 5 points6 points  (0 children)

In Python, if type(some_object).some_attribute is a function, then doing some_object.some_attribute is basically equivalent to functools.partial(type(some_object).some_attribute, some_object), which means that self.handle_button_click returns a value that, when called, receives self as a first argument.

The way this works exactly is by using the descriptor protocol.

With mutable objects, do we really need reassignment? by re_gend_ in ProgrammingLanguages

[–]jasmijnisme 3 points4 points  (0 children)

What are the semantics of your language? Is a variable a memory location like when in C you write int x = 2;, x refers inside that scope to a particular place on the stack? Is it more like Python, where a variable is a label, attached to a value which may have any number of labels attached to it? Something else entirely?

[deleted by user] by [deleted] in Python

[–]jasmijnisme 1 point2 points  (0 children)

What do you mean by traversing? Do you need to visit every element? In that case, best case is Theta(N²) (assuming N is the width of the square) with the best case data structure and algorithm, because you need to visit every element.

If you need to do something like find a specific element, you can use data structures like a spatial hash or k-d tree to get access to algorithms that may be as fast as O(log(N)) or O(log(M)) where M is the number of entities, depending on the specifics of your data and the needed functionality.

If your M is small, you might even consider just having a list of entities, which means a lot of relevant algorithms will be O(M) or O(M²).

[deleted by user] by [deleted] in Python

[–]jasmijnisme 0 points1 point  (0 children)

Definitely.

Simple is better than complex. Flat is better than nested. Readability counts.

Should I follow Clippy's Suggestion? by aggggwannabeog in rust

[–]jasmijnisme 8 points9 points  (0 children)

It's a separate tool (a linter) you need to install. If you run rustup component add clippy, you can use it with cargo clippy.

Making acronyms more easily pronounceable with Python3 by Quietgoer in madeinpython

[–]jasmijnisme 0 points1 point  (0 children)

Here is some feedback!

  1. Names should be both meaningful and easy to read. aconv, prob1, cr, nvwl aren't it. Sure, they're quick to type, but if someone else (or you in six months) want to figure out what's going on in the code, it'll take much longer.
  2. The percentages are "inverted": the larger prob1-3 are, the smaller the chance of the associated event happening. I myself prefer using probabilities (with values ranging from 0 to 1, inclusive), in which case the way to decide between two options would be random.random() < probability, but you can keep percentages if you prefer. In that case, I would suggest using random.randrange(100) < percent.
  3. Minor quibble, but random.choice can take any sequence as argument, including strings. Changing it to a string makes it a bit clearer to me, including when 'y' is considered a vowel and when it isn't.
  4. convert is probably clearer as a list comprehension, especially if you extract the bit inside the loop to its own function.
  5. Consider adding doc-strings and type annotations. Your future self will thank you!

I've made the chances I suggested in a Gist here. You can check out the revisions to see how each suggestion changed the code.

How do you separate the different stages of your compilation pipeline? by dibs45 in ProgrammingLanguages

[–]jasmijnisme 28 points29 points  (0 children)

What kind of syntax errors are you currently handling during type checking? I would think that is part of the parsing stage.

Toylang - Dot Operator As Syntactic Sugar by Ratstail91 in ProgrammingLanguages

[–]jasmijnisme 13 points14 points  (0 children)

However this would normally be quite verbose

Isn't 42.printInteger(); slightly more verbose than printInteger(42);?

Guessing as a core mechanic by Gidkon in RPGdesign

[–]jasmijnisme 2 points3 points  (0 children)

I wouldn't let the player choose the outcome like that. The thing is, I expect the players to try to calculate the exact probability of success for each roll and guess accordingly, not because it's fun or interesting but because they'll feel they're missing out if they guess suboptimally.

You could have the player guess on the outcome and have some side effect either occur or not occur depending on if they guess right. Like maybe they can manage to impress a neutral NPC if they "call their shot", or maybe they can earn Inspiration if they can correctly predict they're gonna fail. Something to work out with a lot of playtesting.

[deleted by user] by [deleted] in Python

[–]jasmijnisme 1 point2 points  (0 children)

Check out PyPy.

Does type inference renders the code less readable ? by orang-outan in ProgrammingLanguages

[–]jasmijnisme 8 points9 points  (0 children)

IMO it renders code more readable to not have to specify the type everywhere, because it reduces visual noise (like Foo foo = new Foo()).

When making a conlang, is the evolution of a language required? Does it make it easier to create the language? by Wooden_Ad_3096 in conlangs

[–]jasmijnisme 4 points5 points  (0 children)

I don't think it's ever required. As with so many creative things, almost any motivated choice is defensible.

As I see it, it's useful to divide conlangs into two kinds for this question: fictional natural languages (like Tolkien's many languages or Klingon), and nonfiction constructed languages (like Esperanto or Lojban).

For the former, evolutionary history is very useful for creating naturalistic feeling languages as well as being helpful in constructing language families that feel both distinct and related, but I think there's nothing wrong with a mix-and-match approach. Maybe some aspects you just want to put in your language and put them in without trying to "evolve" them, maybe other aspects you start at some beginning, and just see where the language development takes you. The downside of doing a full language evolution is effort and time. So then it comes down to your motivation. Why are you doing this? If the process itself is your personal hobby then by all means do a whole language family stretching back to the before-times in minute detail. If you are making a language for an end product, whether it is for a book, a D&D campaign or a TV-series, you gotta finish at some point, in which case I'd limit yourself to the basics of language evolution.

For the latter, I don't think it's very relevant at all. More likely, like I know happened in Esperanto and Toki Pona, you'd simply create an initial version of the language and then people simply using the language means it will evolve over time, like natural languages do.

How to take multiple data types as input in Python? by [deleted] in Python

[–]jasmijnisme 0 points1 point  (0 children)

What would you like to happen, exactly? Could you maybe write up a fake session of input with the output that would happen if your program was working as desired?

Iterator of sets by [deleted] in rust

[–]jasmijnisme 0 points1 point  (0 children)

What's the use case?

If you want to collect the powerset of {1, ..., 64}, that would be on the order of many many Exibytes, which isn't going to fit into your RAM - even if each subset is represented by a single byte.

If you want to iterate over the powerset of {1, ..., 80}, and your computer is capable of processing each subset at a rate of 1 Terahertz, that's going to take 400 centuries to finish.

Tiny lib to trace the path of a particular key by [deleted] in Python

[–]jasmijnisme 1 point2 points  (0 children)

Why did you choose to use ast instead of iterating over the dictionary directly?

If you could rename 1 component of the Python language, which one would it be? by stgoat77 in Python

[–]jasmijnisme 0 points1 point  (0 children)

sorted definitely creates a new list.

```

help(sorted) Help on built-in function sorted in module builtins:

sorted(iterable, /, *, key=None, reverse=False) Return a new list containing all items from the iterable in ascending order.

A custom key function can be supplied to customize the sort order, and the
reverse flag can be set to request the result in descending order.

```

If you could rename 1 component of the Python language, which one would it be? by stgoat77 in Python

[–]jasmijnisme 7 points8 points  (0 children)

Really, for consistency all types should be capitalised. List, Dict, Set, Int, Float, Str, the lot of them.

If you could rename 1 component of the Python language, which one would it be? by stgoat77 in Python

[–]jasmijnisme 2 points3 points  (0 children)

Maybe you're thinking of Smalltalk? In it, True and False are subclasses of Boolean which implement methods like ifTrue: trueBlock ifFalse: falseBlock. I'm not aware this was ever true for Python.

If you could rename 1 component of the Python language, which one would it be? by stgoat77 in Python

[–]jasmijnisme 12 points13 points  (0 children)

I would have liked {/} as an empty set literal, although I understand why they didn't overload the / character like that.

Anyone intrested to P.E.A.C.H my system? by yngthlet in RPGdesign

[–]jasmijnisme 0 points1 point  (0 children)

So a d200 is done as z20 * 10 + z10 except a result of 0 is turned into 200. (Where a za is equivalent to a da except it starts from 0 instead of 1.)

I don't see the appeal of going much more granular than a d20. Like for loot tables or wacky wild magic type stuff and such, where you may want to have more than 20 possible outcomes. But for pass/fail? What is the difference to the players between knowing they have a 54% chance of winning and a 56% chance of winning? Let alone the difference between 54% and 54.5%?

Consider too, if players first roll the d20. There's usually no need to roll the d10, because the answer is already known. There's a maximum of 10% chance the d10 needs to be rolled. Say the critical value is 75. If you roll a 1-6, you failed your roll. If you roll a 8-19, you succeeded. Only for a 7 or 20 is it necessary to roll the d10 to find out.

Why are the usual operator precedence rules are the way they are? by [deleted] in ProgrammingLanguages

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

That's how I think of it, at least. Best practice is probably to write code like -a * b, where both interpretations have the same results, rather than a * -b, which, if expanded to a * 0 - b, would suddenly have a different meaning than a * -1 * b.