« first day (505 days earlier)      last day (4443 days later) » 

12:43 PM
@LewsTherin Hello, what did you read?
 
1:30 PM
0
Q: How to Dynamically Set Template Property Options

Kian MayneI would like to have a template property for my customer button template that includes different options which affect the content of an image. I.e. Close Maximise Restore Minimise So when the user of the control wants to set the type of button to maximise, they pick it out of a drop down in ...

 
 
2 hours later…
3:33 PM
hi
 
hey
 
hello
 
how're you
 
@Patrick hi there
@LewsTherin I'm fine. Thanks, how are you?
 
@yas4891 Pleasant day today, so mostly fine :P
 
3:34 PM
hmm. it is cloudy over here
 
It is actually sunny, for once.
It is temporary however
 
The sun always shine ;)
or burn.. whichever way you see it
 
Lulz, doesn't burn hot enough
 
:P
stupid sun.. I challenge you to burn us more!
we're freezing down here!
 
xD
I just fear for those in Africa
 
3:38 PM
But don't burn when I'm on my computer, the glare in my computer screen is painful
thank you in advance, a long time user
@LewsTherin hehe
 
@Patrick xD
I would probably be at the beach though :D
 
@LewsTherin That would be nice
 
lol
 
In reality it is unlikely to happen
"That would be nice" about sums it up.
 
3:57 PM
bachelor thesis suckz
 
wut
Can you explain something for me
The Enumerable.Select method
Takes an element and modifies it.. but not actually it. It modifies a copy, right?
Or it takes an element, returns the modified value of that element.
 
@LewsTherin It probably depends if it's a reference type or value type
references are probably passed "as is", because cloning/copying an object is not as easy as it sounds
 
Well, I'm just considering an array of ints.
 
value types are passed as copies, due to the nature of them
 
Enumerable.Select() works on a real copy of the IEnumerable, but not copies of the elements in the IEnumerable
 
4:08 PM
int []arr = new []{1,2,3,4,5};
arr.Select(elem=>elem*2) ;
So does it use the actual elem or a copy of the elems?
@yas4891 Um..
So it makes a copy of the IEnumerable object and works on that?
So in this case, it makes a copy of arr and modifies that copy and returns a reference to it?
 
yes, at least that's the way you should think about it. In reality it is quite a bit more complex
 
All Enumerables are collections of some sort aren't they?
@yas4891 mmn, I suppose.
 
IEnumerable objects . yes
 
Your explanation works for me lol
 
@LewsTherin It doesn't, but only because your working with int 's (a value type)
 
4:12 PM
@LewsTherin great :)
 
What if I am working with a reference type
 
Value types are local to their method scope so to speak
@LewsTherin Then, as I explained earlier, it's passed as is
You can't "just copy" a reference type
 
well... as usual the reality is more complex...
 
Why not just copy the reference to that object?
 
@LewsTherin that is what is done
 
4:14 PM
Why is elem*2 returned?
 
@LewsTherin But your still refering to the reference.. Yes, in reality a reference is passed by value, but only because what actually gets copied is the pointer value, not the instance it self..
 
@Patrick That's what I was referring to. I think that anyway because well everything is pass by value
.Select(elem=>elem*2) If the copy is modifed, why does it have to be returned? And where is it returned to. That part is confusing me.
It sounds as if the new collection is grown on the fly
 
@LewsTherin It is...
select kind of works like this:
 
So the copy of the array is only created when that query is executed.
 
public IEnumerable<T> Select(Func<T, T> modifier) {
  foreach (T element in this) { yield return modifier(element); }
}
@LewsTherin well..yeah, that's one way of looking at it
 
4:19 PM
@Patrick That looks horrible
 
@LewsTherin It does? Why?!
 
@Patrick So many T's and angled brackets. :P
mmn
 
ROFL
 
..okay.. thanks for dissing my code
;)
 
Sorry :D
What does yield do again, sorry. I remember from a video it kind of collects the returned values.
Agh will check the darn specs
 
4:21 PM
I thought it was very clean. I even left out the type parameter on Select as to not make it messy.
 
Type parameter?
 
Yes, when using generic methods you specify a type to "work on"..
 
Oh right
 
as in public void DoSometing<TypeParam>()
 
Like Func<int,bool>
I understand that way better for some reason :P
 
4:23 PM
@LewsTherin Func<> is a class, you can have type parameters with methods, too
 
I suppose Select<T>(,) then?
 
yes
 
@LewsTherin You are correct
 
What does the yield return that you had do?.. MSDN as usual doesn't help
 
@LewsTherin It delays the execution when "constructing" the list
So the second element is not "created" until the processing of the first item is complete
 
4:26 PM
So it simply says when "when the new element has been successfully created, move on to the next element" or something like that?
 
You can see this if you slap in a Console.WriteLine before the yield
 
Console.WriteLine("C#") yield ;?
 
Notice that the output is not "yeild 1 yield 2 item 1 item 2"
 
.NETPad! very cool.
Interesting.
 
So yield actually breaks execution of the function test and continues where it was when a new item is requested.
 
4:31 PM
That seems slow
 
The concept is called a continuation, en.wikipedia.org/wiki/Continuation
 
Why would I even want to do that
 
@LewsTherin What do you mean with slow?
 
Just the fact that I have to remember where I am whenever I break out of the loop
 
@LewsTherin Well, given this you could write a list that has in theory an unlimited number items
 
4:32 PM
Going back and forth doesn't seem intuitive
 
haha, you don't have to remember that, that's up to the CLR :P
 
@Patrick Yeah, sorry I was referring to the CLR xD
 
@LewsTherin With that logic, you wouldn't need functions either
 
Functions are logical to me. But I think I see what you mean. It is like saying
why do I need stream.ReadLine() in a loop?
So I suppose yield gets as much as the external for loop needs?
 
yield is another word for "delay execution"... sort of
 
4:36 PM
But why would I need deferred execution in this case? It is pretty clear I want the whole list, just give me it at once ha ha
Sorry, I am trying to see the point of this concept. As always
 
Well, I gave you a reason earlier... The thing is you don't have to create a list and then return it, so you can modify the items returned while you are processing
Which means you can, for example, create a collection with unlimited items
Consider allocating the memory for that in advance..
 
@Patrick This doesn't make as much sense.
 
Why not?
 
@Patrick I get this however.
@Patrick Well maybe it does for you. But how does it create collection of unlimited items?
 
Delayed execution means you don't have to create a list and then return it, which saves memory and execution time
 
4:41 PM
For example of course
 
public IEnumerable<int> endless() {
  int i = 0; while(true){ yield return i++; }
}
 
So basically, instead of having two objects in memory.. I have only one?
 
@LewsTherin Two objects?
 
@Patrick You said it saves memory and execution time. I am try to understand what that means.
And two objects is wrong by the way lol
 
@LewsTherin Memory: if you are creating objects in a loop, they are created only when they are requested. Execution time: If you break out of a loop, the rest of the items in the IEnumerable are not fetched
 
4:48 PM
I would have to read something on this properly.
 
This makes more sense if you consider that not everything lives on your computer. Loading a resource from the Internet or a resource share can take some time.
 
It appears we have this already with the break/continue statement
@Patrick btw thanks very much.
I mean I know how yield works.. I just don't see the point. I never see the point
Why!? :(
 
 
2 hours later…
7:39 PM
Someone know if it's possible to do something like this: stackoverflow.com/questions/9558152/… ?
 
hey, anybody in?
 
8:06 PM
Anyone well versed with static concepts?
 
 
1 hour later…
9:22 PM
Hey
 

« first day (505 days earlier)      last day (4443 days later) »