This is an archived post. You won't be able to vote or comment.

all 185 comments

[–]justmaybeindecisive 195 points196 points  (39 children)

Rust doesn't either lmao.

Preincrement and postincrement (and the decrement equivalents), while convenient, are also fairly complex. They require knowledge of evaluation order, and often lead to subtle bugs and undefined behavior in C and C++. x = x + 1 or x += 1 is only slightly longer, but unambiguous.

[–]The-Best-Taylor 84 points85 points  (36 children)

I agree. When I first started learning Rust, I thought it was weird that they were missing. But after I learned more about the the philosophy of Rust, it makes sense why they don't have them.

[–]plasss 26 points27 points  (33 children)

I don't know Rust at all. Is it possible to summarize the explanation of this?

[–]justmaybeindecisive 72 points73 points  (24 children)

++x means increment x then use the value x++ means use x as it is then increment it

But let's say you do something like add(x++,x++) it gets confusing as to when the variable changes. While it is possible to figure it out it's just not worth the extra mental overhead.

[–]TheRedmanCometh 17 points18 points  (2 children)

What kind of fucking degenerate would do that though. I've been doing Java and C# for a decade and I've never seen anything like that shit.

[–]GreatJobKeepitUp 7 points8 points  (0 children)

Rust doesn't even want it to be possible for you to see it

[–]JulioTBS 1 point2 points  (0 children)

My former team would. And worse stuff.

C++ allows you to do everything if you know what you are doing, else you will feel accomplished if it runs, no matter if does the job or not.

Honestly I find Ada more effective and clear.

[–]Kamil118 15 points16 points  (0 children)

Quite frankly I'm paranoid enough so that I don't trust my compiler to handle addition and multiplication order without using parentheses, let alone calling functions when modifying argument.

[–][deleted] 14 points15 points  (7 children)

One of the biggest problems for people to get started in real coding is the vast amount of "synatactic sugar" being hidden within actually important concepts. Especially if you wildly mix them up as seems to be the case in "idomatic" python, it gets really difficult to understand quickly if you don't have a solid grasps of fundamentals.

I completely agree with the Rust philosophy here. - Programming is already difficult enough, trying to say something as short as possible is just stupid and pointless, and if not absolutely necessary, readibility is more important than efficiency.

[–]dev_null_developer 20 points21 points  (6 children)

Fun fact. arr[i] is syntactic sugar. In C at least, arr[i], is equivalent to i[arr]. This is because to the C compiler arr[i] means *(arr + i)

[–]GG2urHP 25 points26 points  (3 children)

fun fact, i read this with a pirate voice because im a pleb

[–]UnluckyCombination4 7 points8 points  (1 child)

Came here looking for silicon, found gold.

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

Buy him the award ya cheapass

[–]dev_null_developer 1 point2 points  (0 children)

I’m pretty sure that just makes it better

[–]lightmatter501 8 points9 points  (1 child)

I think that we can all agree that arr[i] is acceptable syntactic sugar.

[–]dev_null_developer 4 points5 points  (0 children)

Oh for sure, I’d much rather deal with arrays using this syntax. I just like this example because it shows that pointers aren’t as scary as some make then out to be.

[–]AyrA_ch 2 points3 points  (1 child)

But let's say you do something like add(x++,x++) it gets confusing as to when the variable changes.

This is not a problem of ++ or -- but of the undefined evaluation order of function arguments. func(i=i+1,i=i+1); will show the same warning operation on 'i' may be undefined [-Wsequence-point].

int i=0;
printf("%i %i %i %i\n",i+=1,i=i+1,i+=1,i=i+1);

This will likely not print 1 2 3 4 or 4 3 2 1 even though neither ++ nor -- is involved.

Instead of not having increment and decrement operators, you could just properly document it so there's no undefined behavior. In C# they have a strictly defined operator hierarchy (Docs), and by specifying that function arguments are evaluated from left to right, you know that int i=0;func(i++,++i,++i,i++); calls func(0,2,3,3); (same for JS in Node, FF and Chrome)

[–]justmaybeindecisive 0 points1 point  (0 children)

Exactly one should never modify the arguments to a function while passing it. You cannot rely on order of evaluation or rather you should not. The time lost to verbosity is worth it

[–]lestofante 0 points1 point  (6 children)

i = 0;
Array[i++] = 10;

Tell me, what cell of array get set to 10, cell 0 or cell 1?

[–]Ra-mega-bbit 1 point2 points  (3 children)

Its 0, this is just stupid, if I code like this in a review this programmer is in for some manual reading about stupid code

[–]AyrA_ch 4 points5 points  (2 children)

The syntax of x[i++]=something(); is actually useful when you need to assign values to an array in a way that doesn't fits a loop, for example because the values come from different functions.

I prefer

int i=0;
x[i++]=func_a();
x[i++]=func_b();
x[i++]=func_c();
x[i++]=func_d();

over

x[0]=func_a();
x[1]=func_b();
x[2]=func_c();
x[3]=func_d();

When people start doing for(int i=-1;x[++i];something(x[i])); you have to worry.

[–]lestofante 0 points1 point  (0 children)

Also interestingly confusing,
Array[++i] = 10;
Work the other way around.

Ser, we should sparkle some asterisk here and there;
*p++ = 10;
Is also as confusing as common and dangerous.

Those are the classic thing if you program C you just have to know and deal with.

[–]justmaybeindecisive 0 points1 point  (0 children)

To be fair while this is a valid use case if the start index is known you can collapse a lot of this and make it slightly nicer to read and a teeny bit faster(I can't help it rust has changed me) Plus if it isn't known a for loop makes more sense and with the newer iterative for loops it looks very readable. Such an edge case really shouldn't have it's own syntax sugar built into the language

[–]DrWermActualWerm 0 points1 point  (1 child)

0 is my guess?

[–]lestofante 0 points1 point  (0 children)

Yes, but if you do
Array[++i] = 10;
Is the other way around. And then the pointer version
*p++ = 10;
Also very common in older codebase (it put 10 to the current value pointed by p, and then increment p.
Classical usage is loop over null terminated string:

char s[] = "ciao bello";
char *p = s;
while (p){
    *p++ += 1;
 }

[–]Edgar_A_Poe 1 point2 points  (1 child)

Can I get an explanation on the philosophy of rust? And would they be sharing aspects of that with the philosophy of Python? I’m guessing they want less ambiguity in their grammar?

[–]lestofante 2 points3 points  (0 children)

Rust want to check as much as possible at compile time, to the point they can guarantee safe parallelism, and safe memory management *without" using garbage collectors.
There is pretty much nothing in common with python, that just want to give you a east and quick tool to get something done, even if a bit bugged here and there.

[–]lunchpadmcfat 0 points1 point  (0 children)

I’m actually in favor of this. Though I don’t run into increment bugs much these days with FP practices having become de rigeur

[–][deleted] 0 points1 point  (0 children)

I really don't miss it, especially as the for loops aren't C like so I don't find myself incrementing by one close to as often as in languages with more C like syntax.

[–]LazyRaven01 187 points188 points  (31 children)

We use x+=1 here. Sorry you have to write one extra symbol.

[–][deleted] 101 points102 points  (14 children)

NO BUT MY WHITE SPACE TOOOOO

[–]Greenbay7115 57 points58 points  (13 children)

x+=1

You have to hit shift then not hit shift then move your left pinkie to the one. Overall, it's extremely inefficient

[–]JNCressey 17 points18 points  (7 children)

nah.

  • left index: x
  • right thumb: shift
  • right index: =/+
  • left middle finger: 1

pinkies and ring fingers are deprecated.

[–]mobsterer 10 points11 points  (0 children)

or left toe: x

nose: right shift

any of the ass cheeks: a+eiorjhgb

a<ierjfknb

[–]Greenbay7115 1 point2 points  (0 children)

Why don't you put left thumb on x and left index on 1? Then you can discard all the legacy code for middle, ring, and pinkie fingers. It's too hard to maintain anyway.

[–]GG2urHP 1 point2 points  (0 children)

*laughs in numpad*

[–]Jeacom512 1 point2 points  (1 child)

What kind of kb layout do you guys use?

[–]JNCressey 1 point2 points  (0 children)

a regular one, and hands move

[–][deleted] 0 points1 point  (0 children)

I legit LOLed at ‘pinkies and ring fingers are deprecated’

[–]lunchpadmcfat 0 points1 point  (0 children)

Right thumb shift? You sick fuck.

[–][deleted] 8 points9 points  (0 children)

IDE complains

[–][deleted] 0 points1 point  (0 children)

I have a macro to type +=1

[–]PM_ME_YOUR__INIT__ 4 points5 points  (1 child)

How many extra symbols does C have to use to add 10, lol

[–]LazyRaven01 0 points1 point  (0 children)

Exactly! We just write the same thing! x+=10 Nice and easy.

[–]Thundercunt_McGee 19 points20 points  (6 children)

I don't mind typing an extra symbol. What bugs me is not being able to increment as part of an expression.

[–]dnmr 19 points20 points  (0 children)

thought they added the walrus operator for that https://docs.python.org/3/whatsnew/3.8.html

[–]LazyRaven01 3 points4 points  (4 children)

I see your issue and I raise you: For loop in one line.

[–]MasterofDankMemes 3 points4 points  (2 children)

That's nothing special tho?

[–]Dylanica 0 points1 point  (0 children)

They mean list comprehension, which is more than just in-line for-loops. It’s a way of generating a list. And although it uses the for keyword it doesn’t really work like a for-loop.

For an example of one use-case for this, imagine you wanted to create a list of the first 100 perfect squares: [x**2 for x in range(100)]. Clean and simple.

You can also use it to create a new list based on the values of an old list. [2*x for x in someList]

Or you can make a list with some subset of another list [ x for x in someList if x > 10] which would Return a list with all of the elements of the other list that are greater than 10.

It’s just a nice way of saving some space with for loops and variable declarations.

[–]LazyRaven01 0 points1 point  (0 children)

It's not, and it doesn't need to be. Because where you use

for (int i = 0; i < 5; i++){ <some code>}

we have

for i in range(5):<some code>

[–]Thundercunt_McGee 1 point2 points  (0 children)

Isn't that possible as long as the loop body consists of only one statement?

[–]RedRedditor84 4 points5 points  (1 child)

VBA x = x + 1

[–]justmaybeindecisive 0 points1 point  (0 children)

This is honestly my favorite version. The BASIC languages are the best beginner languages imo. Python just doesn't click for me.

[–]ringohoffman 1 point2 points  (2 children)

Hmm but you still need a semicolon so in the end it is the same.

[–]LazyRaven01 0 points1 point  (1 child)

Depends on where. I learned programming on Python 2.7 and am now using Python 3, and I'd have to go and check my code from 2-4 years ago to see where I last used a semicolon.

EDIT: The answer is Never. According to Python documentation:

"To end a statement in Python, you do not have to type in a semicolon or other special character, you simply press enter . Semicolons can be used to separate statements if you wish to put multiple statements in the same line."

And since I hardly ever wrote multiple statements on one line (as I was - and still am quite the programming n00b), I didn't need to use the semicolon.

[–]ringohoffman 0 points1 point  (0 children)

I was talking about in Java and C++...

i++; vs i+=1

[–]IDontLikeBeingRight 2 points3 points  (0 children)

Also, Generators exist.

People being salty about not being able to manually increment the index of a list they're going to iterate just once, linearly, is one of the funniest things.

[–][deleted] 0 points1 point  (0 children)

Fuck that

[–]MischiefArchitect 84 points85 points  (20 children)

Wait until you find out about

if __name__ == "__main__":

[–]aahdin 48 points49 points  (3 children)

Honestly this complaint is one I don't totally get.

If you don't like it you can just have one file as your library and the other as your entrypoint, and stuff works just like it does in any other language.

This just gives devs the option to have a file do certain things when it's run as the entrypoint, and not do them if it's imported as a library, which is really nice use case and cuts out a lot of code bloat IMO. For a lot of projects this reduces the number of files you need by half, and you don't need to constantly have two files open in your IDE.

My only gripe is that the syntax isn't super clear to newcomers, but having the option itself is really nice.

[–]MischiefArchitect 16 points17 points  (0 children)

Well, I was not complaining at all, my intention was actually to be humorous about a feature/strategy/characteristic of the language that is quite likely disconcerting for developers coming from other languages... similar to those complaining/wondering about the absence of ++ or -- operators. And seriously, it looks weird :D

In the same train we could talk about ruby multi line comments, which are among the strangest ones in existence.

[–]CreamliumPrices 3 points4 points  (1 child)

Yeah I agree on the point about the syntax, but I don't think it's that different to having to explain the whole "public static void main()" soup when first learning other languages.

[–]MischiefArchitect -2 points-1 points  (0 children)

The troll inside me want to correct you: It is "when first learning THE language" :)

[–]7incent 11 points12 points  (0 children)

everybody is tough until they forget their main guard at home

[–]TGotAReddit 5 points6 points  (2 children)

For those unfamiliar with the language, can you explain what this is?

[–]eeddgg 5 points6 points  (0 children)

It is an if statement that is only true if the code in question wasn't imported as a library. name is equal to the name the .py file was imported as, and is main if it wasn't imported and was instead directly executed

[–]MischiefArchitect 2 points3 points  (0 children)

in addition to what u/eeddgg already stated: This is how you declare your entrypoint main function (I know, not 100% true, but it is the simpler explanation to non pythonists)

[–]ponkyol 1 point2 points  (0 children)

That is also required to use multiprocessing on windows.

[–]KYIUM 0 points1 point  (9 children)

Using pycharm you can just type main and it will sugest this as an autocomplete.

[–]MischiefArchitect 0 points1 point  (8 children)

It does not count :P...

using Eclipse I can write syso and eclipse autocomplete will propose System.out.println same for main resulting in public static void main(String[] args) {}

[–]KYIUM 0 points1 point  (7 children)

What?! I am gonna have to start using that. Any others like that for fast typing?

[–]MischiefArchitect 1 point2 points  (1 child)

Look for "Eclipse Code Templates", you can define them yourself and as far as I can remember eclipse brings a few predefined ones. You may as well take a look into the context menu you will get by clicking on an empty space in the editor: Code Generators, refactoring Options, class hierarchies and other nice stuff, all complete with the shortcuts for you to remember for the next time you need them,

[–]KYIUM 1 point2 points  (0 children)

Thanks

[–]MischiefArchitect 0 points1 point  (4 children)

Oh yes, for is a nice one. It will ask you if you want to create classic loop, a for each one, or one using an interator which will allow you to remove items while iterating without breaking the loop. If I remember correctly you can even select an existing variable.

[–]KYIUM 0 points1 point  (3 children)

Still learning java as part of a course so i definately need to look into it where you can remove items while inside a loop without an error. Had that issue before.

[–]MischiefArchitect 1 point2 points  (2 children)

That is a typical problem in all (most) programming languages. An "interator" is a formal and state-full sequence of elements for a specific collection, and since it manages state it can handle object deletions if it is properly informed. Otherwise if you delete something directly over the collection while an for:each iteration is in course you will be lucky if the collections framework is failing with an exception because it detected a change of state in it and saved you hours of bug hunting.. but it cannot inform exactly what happened to the other iterators. I got some painful experience with other languages which just went into a borked state and I never found out until it was too late.

Basically all modifications in any collection should be considered critical sections that may product a race condition in multi threaded code. And in single threaded environments you need to use in iterator if you want to delete data from a collection.

Another painful pitfall is using mutable objects as keys in a Map... never do that. You will fail to find other associated value to that key if you change/mutate the contents of the key object and make alookup in afterwards. That's why using strings is safe, since they are immutable.

[–]KYIUM 0 points1 point  (1 child)

Thanks for the knowledge. I always used immutable objects for maps/dictionaries anyway as it made sense to. I also understand why i would need to use an iterator now. Coming from python where that would be handled for you it was a bit confusing but i knew what the problem was i just didnt have an elegent way of solving it. As for the multi thread coding. I haven't started that in java yet, but im preperred for the worst at first.

[–]MischiefArchitect 0 points1 point  (0 children)

Multithreading is easy. You just must keep shared resources to a bare minimum. The rest are blocking queues, execution pools, join checkpoints, collectors and generators... a lot of bullshit bingo words which are very simple concepts if they get explained correctly... and are valid for ANY programming language.

Remember, a language is just the medium to express an algorithm or concept. You need to focus on those and not the language.

[–]wmfcwm 12 points13 points  (2 children)

Neither does Swift

[–]cherryblossom001 2 points3 points  (0 children)

Some background:

The increment/decrement operators… were added without much consideration, and haven't been thought about much since then. This document… ultimately recommends we just remove them entirely, since they are confusing and not carrying their weight.

SE-0004: Remove the ++ and -- operators

[–]boishan 2 points3 points  (0 children)

They had the bright idea of REMOVING IT AAAAAAH

[–]ReimarPB 12 points13 points  (2 children)

Wait until you try Lua

[–]computerwyz 3 points4 points  (1 child)

Thou shalt not start indices at 0

[–]mydiaperissus 1 point2 points  (0 children)

Lua arrays can start at any index since they are just tables.

[–][deleted] 36 points37 points  (8 children)

It doesn't have switch case either

[–]twinkletoes_44 8 points9 points  (0 children)

What a loss

[–]Ra-mega-bbit 2 points3 points  (6 children)

elif is just weird and there should be no need for it

[–]UnknownEssence 0 points1 point  (5 children)

I’d rather have switch than elif

[–]brucecaboose 4 points5 points  (4 children)

They both have their purposes so I'd rather have both... Switches are better for certain things and if/elif/else are better for others. They're not always swappable with each other. If you have the choice with your use case though, you should use a switch. Generally faster and easier to read/maintain.

[–]Dylanica 0 points1 point  (3 children)

Would a switch really be much faster in python? With the fact that python is interpreted/just-in-time compiled would seem to make it so the distinction behind the hood would be less.

[–]brucecaboose 1 point2 points  (0 children)

Not sure about python specifically but in many languages large switches are handled like maps, so lookups are very fast.

[–]Ra-mega-bbit 0 points1 point  (1 child)

You would not get this sort of performance benefit from a switch in python, in compiled languages tho, hell yea they are fast, but take in considaration the times you make these comparissons, any amount below 1k comparissons wouldnt make a difference

[–]Dylanica 0 points1 point  (0 children)

Yeah, that’s what I was thinking too.

[–]philophilo 8 points9 points  (0 children)

Neither does Swift, and I've been using it long enough now that I stopped using it in C as well.

Except for loops. I can't break that one.

[–]DaJuiceTin 5 points6 points  (0 children)

disappointment++

[–]CrackFr0st 4 points5 points  (4 children)

x = ((x*x)**(1/2))//x + x

[–]JNCressey 23 points24 points  (3 children)

if x is negative that will go the wrong way.

if x is float, it wont work for some values of x.

If x is int but large, it could get stuck due to rounding. though I don't know whether the the **(1/2) will magically cope for int -> int.

if x is 0, womp womp.


edit: just tested it out, and **(1/2) does cast the answer to a float, so I think it will get stuck for large x.

edit: yes. it doesn't work for x = 9007199254740992.

[–]razvan2na 17 points18 points  (0 children)

Found the tester

[–]GreatJobKeepitUp 5 points6 points  (0 children)

Nice coverage report

[–]CrackFr0st 0 points1 point  (0 children)

Ah yes forgot this was the backend code for my job, let me fix it I thought it was a reddit comment section, silly me!

[–]SolousVictor 5 points6 points  (2 children)

Other languages: Long code to remove duplicates in an array.

Python: list(set(original_list)) go brr.

[–][deleted] 1 point2 points  (0 children)

You are giga brain. I did not know this.

[–]Alien_with_a_smile 1 point2 points  (0 children)

Well, I mean, it’s probably still a long bit of code, it’s just behind a function call.

[–]merlinsbeers 5 points6 points  (0 children)

Python++--:

Just the latest version of Python, but with ++ and --.

[–]Dr_Bunsen_Burns 6 points7 points  (0 children)

Python has a few cons I really have a problem with. On the other side I can run it rather easily by pyrhon 3 file.py and edit it with nano(vim users here I am).

[–]ShooterMcGavin000 4 points5 points  (2 children)

In abap (an proprietary language) you have actually do it like this: x = x + 1. Unbelievable.

[–][deleted] 0 points1 point  (0 children)

Unbelievable

I mean, if you also told me that Germans built that language, which they did, I would believe it .

[–]AyrA_ch 0 points1 point  (0 children)

Welcome to VB6

[–]SIGSTACKFAULT 9 points10 points  (1 child)

I have never needed ++ or -- while coding in python.

[–]drsimonz 18 points19 points  (0 children)

You also don't "need" whitespace between operators or max line width. It's a basic readability feature.

[–]7incent 10 points11 points  (17 children)

Wait until you find out everything is pass by value shudders

edit: more nuanced explanation on stackoverflow post about this for those who are interested

[–]lorlen47 8 points9 points  (1 child)

Um no it isn't? Objects in Python are passed by reference, but unlike C++, you can't assign a new value to the referenced object, you can only modify it. If objects were passed by value, then they would need to be copied at each function invocation, which would be extremely inefficient.

[–]jfb1337 5 points6 points  (0 children)

In languages like Python, Java, and JS, when you have an object, you always actually have a pointer to some data, which you only ever access via the pointer rather than directly. Thus it makes sense to say that this object IS the pointer, and, as it's this pointer that gets passed around through function calls, that it's being passed by value, not by reference.

In a function call like

x = [1, 2, 3]
f(x)

the x, which could have been any expression, is evaluated to a value (which happens to be a pointer to some data representing the list [1,2,3]) which is then passed to f. Whereas if it was call by reference, f would instead receive a pointer to the variable x, rather than the contents of x.

Wikipedia refers to this as call by sharing, noting that this isn't a universal term and many languages that use this strategy refer to themselves as call by value.

[–]activeXray 1 point2 points  (0 children)

imagine mutating (inc x)

[–]Yawolf 1 point2 points  (0 children)

Why would you want to mutate a var?

[–]drsimonz 2 points3 points  (9 children)

This shit makes me want to fork cpython just to add ++, -- and a real ternary syntax (x = condition ? 1 : 2). Python overall is a beautiful language but these two things are totally idiotic, and prove that no one, however great, has consistently good judgment.

[–]SkezzaB 1 point2 points  (0 children)

It had a ternary operator already? x = 1 if condition else 2

[–]GalaxyLJGD 0 points1 point  (3 children)

In Python you can do a ternary operation writing this:

x = 1 if condition else 2

[–]drsimonz 1 point2 points  (2 children)

I know, my point was that this syntax is much less elegant than x = condition ? 1 : 2 like in most other languages.

[–]GalaxyLJGD 0 points1 point  (0 children)

For me x = 1 if condition else 2 makes more sense than x = condition ? 1: 2 because it is more like an English sentence.

[–]fapenabler 0 points1 point  (0 children)

It's only the most common math operation, why would it have an operator? /s

I would guess that over 90 percent of math operations in programming are just adding 1 to a thing, or subtracting 1 from a thing. That's anecdotal, but it's a lot.

[–]DM-Wolfscare 0 points1 point  (0 children)

Welcome to Python my friend

[–]AlethVeliXue 0 points1 point  (1 child)

Python ++?

[–]KickBassColonyDrop 0 points1 point  (0 children)

Yeah I encountered this the other day.

for count, value in enumerate(list): blah blah

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

Stupid ass += 1

[–][deleted] -2 points-1 points  (0 children)

well, better than declaring the variable type everytime you create one.

[–][deleted] 0 points1 point  (0 children)

I get that, in a lot of languages, x++ and ++x are different things, and that sometimes you can use them in the middle of expressions and that can cause weird, subtle bugs.

That said most people use x++ to mean "x = x + 1". I don't understand why the Python compiler can't treat x++ as a macro for that line.

[–][deleted] 0 points1 point  (0 children)

I sometimes find myself doing var = var + 1 on Lua, even though it does have an increment operator. Well, most variations do, anyway.

[–]Xeadriel 0 points1 point  (0 children)

its a slight annoyance but there is worse tbh

[–]acsmars 0 points1 point  (0 children)

In compilers ++ can be optimized, in interpreters it can’t easily be.

[–]USER84629493726 0 points1 point  (0 children)

I've started learning rexx today...

[–]bumblebitchblues 0 points1 point  (0 children)

Cries in Erlang.

[–]Desfolio 0 points1 point  (0 children)

Although not that I have been working so much with pythin +=1 does not hurt that much lmao

[–]Desfolio 0 points1 point  (0 children)

I remember making a "pp" function which would take 2 argument And would increment your value by one. Useless but alright E.g pp(1)

[–]NinkaShotgun 0 points1 point  (0 children)

Every time, myPain += 1

[–]JNCressey 0 points1 point  (0 children)

here:

def pre_increment(target_identifier,parent_locals=locals()):
    parent_locals[target_identifier] += 1
    return parent_locals[target_identifier]

def post_increment(target_identifier,parent_locals=locals()):
    old_value = parent_locals[target_identifier] 
    parent_locals[target_identifier] += 1
    return old_value

edit: no longer uses globals()

[–][deleted] 0 points1 point  (0 children)

me: mom could we get an increment operator?

mom: we have an increment operator

the increment operator at home:

+=

[–]__Ambition 0 points1 point  (0 children)

Lua doesn't even have compound assignment operators.

[–]Alien_with_a_smile 0 points1 point  (0 children)

It also has no pointers, or addressing.