« first day (2749 days earlier)      last day (2204 days later) » 

8:00 PM
i mean yes
 
I just put everything in hashmaps
 
i feel like they have very little meaning
if you put them in a collection, or anything using generics, you get a wrapped object anyway
(aka, a class version of them)
 
That's not true
 
you cant extend them
 
Sometimes you want value semantics
 
8:01 PM
generics don't box
 
which might be poor for forwards compat
 
(afaik)
 
generics dont box?
even object o = 1; gets boxed
 
And without structs, you can't really implement Nullable<T>
 
@Grace apart from structs being non-nullable
 
8:01 PM
@Wietlol yeah because that's assigning to a reference type, duh
 
we can do that with classes too
 
@KendallFrey don't say duh, it's insensitive
 
@KendallFrey wait, with generics, C# compiler makes a shit ton of classes for each class right?
like, if somewhere in your code, you use Stuff<Int32>, you get a new class
 
No, you're thinking of templates
generics only have one instance of the code
 
in any case, if you would use the same class, with the same size, the storage where the struct instance is placed must be a reference, so it must be boxed
 
8:04 PM
I'm pretty sure it's not
 
only if you generate different classes for different generic arguments, you can unwrap the structs
like I thought C# did
 
Kids these days would never box their value types.
 
Haskell is great because every type is both a reference and a value
 
I make all my C# types immutable so my programs are more functional.
 
8:10 PM
but for example, if you have a 64 bit operating system, would creating a List<byte> and adding 10 bytes to it have an internal "size" of 10 (10 bytes) or 80 (10 x 8-byte references)?
 
I think it stores it as bytes
 
Yeah, a List<T> is just an array behind the scenes
 
So it'd be weird if it stored it as anything but 10 bytes, plus whatever overhead the list and array itself have.
 
Goddamn it.
 
8:12 PM
so, if I read it as a ReadonlyList<Object> and do list[0], does it box at that moment (when i read from the list)?
 
I didn't mean to paste that here.
 
@Wietlol Well, that's usually not possible, but yes
 
it isnt?
 
Oh, you mean the IReadOnlyList?
that's <out T> so it's fine
 
actually, no its not
Byte does not extend Object
 
8:16 PM
indirectly it does
 
only the boxed version does
 
everything can be casted to object
@Wietlol the what?
 
structs cant
structs will be boxed
so a byte is not an object
 
it is according to is
 
Byte is not right according to T : Object
 
8:17 PM
I'm pretty sure that's not because of byte
 
NH.
yeah, list is not necessarily an IReadOnlyList
 
Try using IList<somereferencetype>
 
 
@Grace that is not a generic
that is boxing
 
298
A: Write a program that makes 2 + 2 = 5

FlonkHaskell I just love how you can throw anything at ghci and it totally rolls with it. λ> let 2+2=5 in 2+2 5

 
8:20 PM
nope, it is because of Byte
 
mcve pls
 
IList appears to not be a readonly list though
so IList will always fail
 
@Wietlol well, that's a different case
@Wietlol that's my point
 
but it is because of Byte
Byte does not extend Object
 
Not the first one
 
8:21 PM
it cant box/unbox them
 
@Wietlol it kind of does
@Wietlol What error does this give?
 
same as before
oddly
 
That's not the same...
I mean, pretty similar, but not the same
 
pretty damn similar
 
125
Q: Why covariance and contravariance do not support value type

Cuong LeIEnumerable<T> is co-variant but it does not support value type, just only reference type. The below simple code is compiled successfully: IEnumerable<string> strList = new List<string>(); IEnumerable<object> objList = strList; But changing from string to int will get compiled error: IEnumerable

 
8:24 PM
so that basically said "Wietlol was right"
 
about what?
 
Byte isnt Object because Object is reference and Byte is not
 
Where does it say that?
 
> Basically, variance applies when the CLR can ensure that it doesn't need to make any representational change to the values. References all look the same - so you can use an IEnumerable<string> as an IEnumerable<object> without any change in representation; the native code itself doesn't need to know what you're doing with the values at all, so long as the infrastructure has guaranteed that it will definitely be valid.
so, it cant box and unbox them
you either need to make a list of boxed value types and get variance or you make a list of unboxed value types and you are on your own
but since you cant actually make the boxing explicit without losing some knowledge about the values, this is kinda a bummer
 
8:28 PM
b is object does a boxed version
 
how do you know?
 
im actually trying to think of a way to make an example
im not sure if you can make the explicit change
 
What about the fact that b.GetType().BaseType.BaseType == System.Object
 
can you see the generated code by the compiler?
 
Sure, hit the View IL button there
 
8:31 PM
GetType() is from Object, it must be called on an object
b.GetType() must therefor be ((object) b).GetType()
 
Since it has these methods that can only be found by inheriting from Object
Would that not imply that it inherits from Object
 
first box, then GetType()
 
@Wietlol Yeah, but that's not the one you were talking about, is it?
 
@Grace the boxed Byte is a class that extends Object and has a byte field
the boxed Byte class is implicit and you are never supposed to interact with it
unlike how in Java, that class is an actual class
eg int - Integer
 
@Wietlol You seem to think there are two different types, one for boxed values, and one for native values. That's not the case.
 
8:35 PM
the byte struct CANNOT extend Object
 
@Wietlol All structs extend object
 
because the struct must be a value type and an object must always be a reference type
@KendallFrey only their boxed version does
 
There is no boxed version of any type
boxing only applies to values
 
im not sure if you are trolling or not
boxing applies to every struct
 
All structs inherit from System.ValueType which inherits from System.Object
@Wietlol Not the struct type, but values of the struct
 
8:38 PM
structs cannot extend classes
not ValueType, not Object
nothing
 
Because the compiler makes them extend System.ValueType
 
yea ok, that might be the reason
 
In C# they don't extend anything, but in the CLR they do
 
in any case, it appears it cant auto-box them
List<byte> has unboxed values
 
covariance? yeah, for reasons explained in that post
 
8:40 PM
that brings us back to the original question, would you miss structs if they were gone
(except for the primitive types)
(aka, bool, byte, short, int, long, float, double, char, etc)
 
oh gosh now you're introducing a new and even more ambiguous term to the conversation
 
I think there's good reason to have DateTime have value semantics.
 
i know primitive actually means that it has stuff to do with the language, but meh
 
I can think of 3 different meanings of primitive
 
i stop at 2
 
NH.
8:42 PM
!!giphy tornado penguin
 
@Grace would that reason be gone if it were a reference type?
 
@Wietlol No...?
 
i mean, what is the reason?
 
Because a date and time simply is what it is. It doesn't have an identity.
You can't have multiple instances of midnight Dec 31 1999
it just simply is that value
 
8:44 PM
isnt that the same with a string?
 
Yes, strings also have value semantics
 
but a string is a class right?
 
yes
well, not a string
System.String is a class and a reference type
that behaves like a value type
 
but for the datetime one, is it really about performance to make it a struct?
 
I suppose struct has a slight performance edge there
I think it's mostly about semantics though
 
8:47 PM
Yeah, it makes sense for DateTimes to be passed by value and whatnot
And for, say, date.AddDays(5) to return a new DateTime representing that date.
 
i guess for bytes and such, I will have to get the boxing to work anyway,
@Grace that can also be done for classes
 
Admittedly, it could probably go either way, but I think you get more of that behavior for free with a struct.
The naive way to implement DateTime is with a regular old mutable class, but I can see the value of it being a value type.
 
the tradeoff here is basically giving up the performance for the support of variance, extending and whatnot
 
And, really, why the heck would you want to extend DateTime
 
I would prefer to have everything be interfaces anyway
 
8:52 PM
(What is a DateTime if not an int holding the number of seconds since some epoch anyways)
 
@Wietlol Is variance really that important?
 
so, that would make everything a reference type
@KendallFrey not directly
 
@Grace well, given that it is in fact not...
 
but i can see how some things might be really annoying
especially if most pair objects are structs
like a KeyValuePair
 
Just use haskell, it doesn't have reference types
 
8:54 PM
 
im not sure if I like haskell any more
 
Sure, it's a little more complicated than that, but not by a whole lot.
 
@Wietlol It has over 50 different numeric types
what's not to like
 
(For one thing, it counts ticks)
 
I will write plain old LLVM IR
it has over 2 million numeric types
 
8:56 PM
is that so
 
yep
maybe
almost 2 million
~1.94 million
 
NH.
Microsoft Help links: at best, links to generic help about the overall product. More often than not, though, the link has completely broken and now just goes to microsoft.com.
 
9:50 PM
trying to convert this piece of code "p = 26570;

c = 299792.458;

A=[];
B=[];
C=[];

m=[];
n=[];

for (var i=0; i<4;i+=1){
m[i] = (pi/2)*(1/3)*i;
n[i] = (2*pi)*(1/3)*i;

A[i] = p*cos(m[i])*cos(n[i]);
B[i] = p*cos(m[i])*sin(n[i]);
C[i] = p*sin(m[i]);

R = sqrt((A[i]-Guess[i])^2+(B[i]-Guess[i])^2+(C[i]-Guess[i])^2);
t[i] = Guess[4] + R/c;

}"
so that "{[(pi/2),0],[(pi/3),0],[(pi/3),(2*pi/3)],[(pi/3),(4*pi/3)]}"
 
10:02 PM
cool story
 
the zeros were throwing me off
nev mind
 
10:16 PM
Can't you just write, like,
new double[] { Tuple.Create(Math.Pi/2, 0) ...
 

« first day (2749 days earlier)      last day (2204 days later) »