TeX was "proven" as a text/typography tool by the fact that the source code written in WEB (interleaving pascal and TeX (this is meta (metacircular))) allows for you to "render" the program as a typographed work explaining how TeX is made+ run the program as a mean to create typographic work.
I'm lacking the words for a better explanation of how do I feel sbout the distinction, but in a sense I would say that notebooks are litterate scrips, while TeX is a litterate program ? (The difference is aesthetical)
I think the idea is that you can't really cover 100% of real-life cases in "code", either legal or software, so the areas you'll leave this out of would be those "not-entirely-strict" parts.
No connection to microsoft.
"Why forbid selling drugs when you can just put a warning label on them? And you could clarify that an overdose is lethal."
It doesn't solve any problems and just pushes enforcement actions into a hopelessly diffuse space. Meanwhile the cartel continues to profit and small time users are temporarily incarcerated.
It doesn't follow. The reverse is more likely: If you end prohibition, you end the mafia.
class EncapsulatedCounter:
def __init__(self, initial_value):
_count = initial_value
def increment():
nonlocal _count
_count += 1
return _count
self.increment = increment
counter = EncapsulatedCounter(100)
new_value = counter.increment()
print(f"New value is: {new_value}") def make_counter(start=0):
count = start
def incr():
nonlocal count
count += 1
return count
return incr
Example: >>> c = make_counter()
>>> c()
1
>>> c()
2
But it hides nothing: >>> c.__closure__[0].cell_contents
2
>>> c.__closure__[0].cell_contents = -1
>>> c()
0
"private" in Python is cultural, not enforced. (you can access `self.__private` from outside too if you want).I’ve found python optimization to be nearly intractable. I’ve spent a significant amount of time over the past two decades optimizing C, Java, Swift, Ruby, SQL and I’m sure more. The techniques are largely the same. In Python, however, everything seems expensive. Field lookup on an object, dynamic dispatch, string/array concatenation. After optimization, the code is no longer “pythonic” (which has come to mean slow, in my vernacular).
Are there any good resources on optimizing python performance while keeping idiomatic?
Otherwise, optimizing code in Python is the same as in any other language eg
Don't waste my time with 70s "ergonomics" (if it can even be called that)
The comparisons with art seem almost to the point of offense to me. You're not building art, you're just building another yet plugin for emacs to do what other people do in maybe 5% less efficient ways but won't spend 2 days automating it
Emacs changes big O. It is not about changing constant factor. If you need N commands with M features then you can implement and combine them in emacs in O(N+M), to get O(N*M) custom commands.
For example, if you need “Search” feature then you can use it everywhere. It can help find you a file in Dired buffer. It can help you find a git chunk in magit. It can help you find todo item in Org mode, etc. It like having a separate `uniq` command instead of implementing it for each shell command (`sort -u` vs. `sort | uniq`). Another example, having `repeat <N> <cmd>` to repeat `<cmd>` command `<N>` times in zsh vs. implementing `<cmd> —repeat <N>` for each command.
The difference is linear vs. quadratic. If you need to do 1000 actions that can be decomposed into 100 commands with 10 features each then in emacs then you need to know and understand ~100 things vs. 1000 in less customizable environments.
I don't mind the idea here, seems good. But I also don't move a block of code often and discover variable assignment related issues.
Is the bad outcome more often seen in C/C++ or specific use cases?
Granted my coding style doesn't tend to involve a lot of variables being reassigned or used across vast swaths of code either so maybe I'm just doing this thing and so that's why I don't run into it.
It is not about mutable/immutable objects , it is about using a name for a single purpose within given scope.
a = 1
b = 2
a = b
"a" name refers to the "2" object. "1" hasn't changed (ints are immutable in Python). If nothing else references it, it might as well disappear (or not).Though both "single purpose" and immutability may be [distinct] good ideas.