« first day (3890 days earlier)      last day (1059 days later) » 

2:27 AM
 
2:40 AM
Hi folks, I found a weird behaviour in Python:
12
A: Why does python/numpy's += mutate the original array?

GoodiesThis is true for almost any type of collection. This is simply due to the way python treats variables. var1 += var2 is not the same as var1 = var1 + var2 with collections. I'll explain it as far as I understand it, which can certainly be improved, so any edits/criticisms are welcomed. print("1:"...

import numpy as np

data = np.arange(10)
roi = data[-3 - 2:-2]

# A
roi = roi + 10

# B
# roi += 10


print(data)
print(roi)
data in A is different from B.
 
 
5 hours later…
7:18 AM
a similar thing happens in Kotlin
+ and += are different operators
plus and plusAssign
they just turn into function calls
so
roi = roi.plus(10)
roi.plusAssign(10)
in the second case, there is no writing back to the variable, the list is just mutated
there is a secondary resolution thingy for the second case though
if plusAssign is not a function for roi, then it attempts to use the same as the first case
iirc
plusAssign() only works for mutable lists, = plus() only works for mutable variables
 
7:56 AM
[Captain Obvious] The same thing happens in C#
 
it does?
 
iirc, C# just translates += to a = a + b
 
[Captain Obvious] The function calls part anyway
 
as a language rule
 
7:57 AM
[Captain Obvious] That's what the default implementation does
[Captain Obvious] But you can override the operators
 
can you override += ?
 
154
A: C# operator overload for `+=`?

VMAtmOverloadable Operators, from MSDN: Assignment operators cannot be overloaded, but +=, for example, is evaluated using +, which can be overloaded. Even more, none of assignment operators can be overloaded. I think this is because there will be an effect for the Garbage collection and memory...

> Assignment operators cannot be overloaded
 
[Captain Obvious] Overloaded =/= overrided
 
still
major difference between the languages
 
7:59 AM
[Captain Obvious] Well yeah
 
in C#, += is a language concept
 
[Captain Obvious] Wouldn't be much point if they were the same
 
the compiler decides that it is the equivalent of = +
in python and kotlin, += is just a function, the implementation decides the behavior
so in C#, numbers += 1; (assuming that there is an overload for IList<T>.Plus(T)
would always just rewrite into the numbers variable
 
8:56 AM
[Captain Obvious] Well no
[Captain Obvious] Because += is just a function in C# too
 
9:53 AM
154
A: C# operator overload for `+=`?

VMAtmOverloadable Operators, from MSDN: Assignment operators cannot be overloaded, but +=, for example, is evaluated using +, which can be overloaded. Even more, none of assignment operators can be overloaded. I think this is because there will be an effect for the Garbage collection and memory...

basically what Wietlol sais, just it's operator + and not some weird interface...
so you can't override += and + differently
the + part will do the same, because there is no operator +=
*overload
 
 
8 hours later…
5:53 PM
Hi all
With ASP.NET ScriptBundles, is there a way to inject a nonce into the script tag that's automatically generated?
 
6:48 PM
Hey All, I'm trying to refresh my memory when it come to the ASP.NET MVC lifecycle. I was taking a look at this pdf ASP.NET MVC lifecycle document: opdhsblobprod04.blob.core.windows.net/contents/…
Could someone please tell me whether the Controller's Action Method associated with a particular invoked URL is invoked before or after the Controller's execute method?
 
mr5
does Controllers have execute method?
 
Basically, what is the order of execution between 1) Controller's Action Method associated with a particular invoked URL 2) Controller's own execute method
 
7:41 PM
@mr5 I think this gives the proper answer: tutorialspoint.com/asp.net_mvc/asp.net_mvc_actions.htm
Once the MvcHandler has a controller, the only thing that MvcHandler knows about is IController Interface, so it simply tells the controller to execute.

When it tells the controller to execute, that's been derived from the MVC's controller base class. The Execute method creates an action invoker and tells that action invoker to go and find a method to invoke, find an action to invoke.
 
 
3 hours later…
10:55 PM
@mr5 Controllers have the "Method" URLs
If you think about a page as a Method, and your signature being the parameters
 

« first day (3890 days earlier)      last day (1059 days later) »