18,130 reputation
93872
bio website ericlippert.com
location Seattle, WA
age 41
visits member for 3 years, 8 months
seen 31 mins ago

Eric Lippert develops C# analyzers at Coverity. During his sixteen years at Microsoft he was a developer of the Visual Basic, VBScript, JScript and C# compilers and a member of the C# language design committee; he is now a C# MVP. He is on Twitter at "@ericlippert" and writes a blog about programming language design and other fabulous adventures in coding at http://ericlippert.com.


Jul
1
awarded  Nice Answer
Jun
30
awarded  Publicist
Jun
28
awarded  Booster
Jun
28
awarded  Announcer
Jun
26
awarded  Great Answer
Jun
19
awarded  Good Answer
Jun
13
comment Is this method pure?
@robertharvey no, they are low level implementation details. Whether a method is pure from my perspective has nothing whatsoever to do with the psychological feelings that developers have about a method. Its entirely about what optimizations a compiler or runtime is allowed to make. Can it memoize the method? Can it execute it lazily? Can the method be split into little pieces and parallelized to multiple threads? And so on.
Jun
9
comment What is the origin of the negative term “Legacy Code”
Write a bunch of code. Check it in. Go get some lunch. Come on back. There's a whole screen full of legacy code! You've now got to understand that code and make sure that all future changes work correctly in the context of that code. Legacy code is the same as existing code.
Jun
6
comment Is this method pure?
Re: your update: Count is pure only if e.GetEnumerator().MoveNext() produces no visible side effect. But when you compose Count with ApplyIterator, we know that items.ApplyIterator(action).GetEnumerator().MoveNext() calls action, and therefore (unless the action is the do-nothing action) Count is not pure.
Jun
6
comment Is this method pure?
@Euphoric: What observable side effect does calling GetEnumerator produce, aside from allocating an enumerator in its initial state?
Jun
6
comment Is this method pure?
@ThomasLevesque: My advice is to never ever do that. A query should answer a question, not mutate a sequence; that's why they're called queries. Mutating the sequence as it is queried is extraordinarily dangerous. Consider for example what happens if such a query is then subjected to multiple calls to Any() over time; the action will be performed again and again, but only on the first item! A sequence should be a sequence of values; if you want a sequence of actions then make an IEnumerable<Action>.
Jun
6
revised Is this method pure?
added 172 characters in body
Jun
6
comment Is this method pure?
I disagree with this answer. Calling sequence.Apply(action) has no side effect; if it does, state the side effect that it has. Now, calling sequence.Apply(action).GetEnumerator().MoveNext() has a side effect, but we already knew that; it mutates the enumerator! Why should sequence.Apply(action) be considered to be impure because calling MoveNext is impure, but sequence.Where(predicate) be considered pure? sequence.Where(predicate).GetEnumerator().MoveNext() is every bit as impure.
Jun
6
answered Is this method pure?
Jun
6
comment Is this method pure?
@IdanArye: ()=>{} is convertible to Action, and it's a pure function. It's outputs depend solely on its inputs and it has no observable side effects.
Jun
6
comment Condition to use polymorphism
@David: This is a question-and-answer site. If you have a question, post it as a question.
Jun
3
answered Overriding GetHashCode in a mutable struct - What NOT to do?
May
23
comment How do I create my own programming language and a compiler for it
@dhams: A device is any thing made for a particular purpose. Every compiler I've ever written was run on hardware that was purpose-built to allow compilers to exist.
May
19
awarded  Nice Answer
May
19
revised Should I expose a “computed” value as a property or a method?
added 190 characters in body