Contents tagged with C# 3.0
-
Lambda Calculus via C# (8) Undecidability of Equivalence
All the previous parts demonstrated what lambda calculus can do – defining functions to model the computing, applying functions to execute the computing, implementing recursion, encoding data types and data structures, etc. Lambda calculus is a powerful tool, and it is Turing complete. This part discuss some interesting problem that cannot be done with lambda calculus – asserting whether 2 lambda expressions are equivalent.
-
C# Functional Programming In-Depth (13) Pure Function
The previous chapter discusses that functional programming encourages modelling data as immutable. Functional programming also encourages modelling operations as pure functions. The encouraged purity for function is the significant difference from method and procedure in imperative programming.
-
C# Functional Programming In-Depth (12) Immutability, Anonymous Type, and Tuple
Immutability is an important aspect of functional programming. As discussed in the introduction chapter, imperative/object-oriented programming is usually mutable and stateful, and functional programming encourages immutability without state change. There are many kinds of immutability. In C#, the relevant features can be categorized into 2 levels: immutability of a value, and immutability of a value’s internal state. Take local variable as example, a local variable can be immutable value, if once it is initialized to an instance, it cannot be altered it to different instance to it; a local variable can also have immutable state, if once the instance’s internal state is initialized, that instance’s internal state cannot be altered to different state.
-
C# Functional Programming In-Depth (11) Covariance and Contravariance
In programming languages with subtyping support, variance is the ability to substitute a type with a different subtype or supertype in a context. For example, having a subtype and a supertype, can a function of subtype output substitute a function of supertype output? Can a sequence of subtype substitute a sequence of supertype? C# supports covariance/contravariance, which means to use a more/less specific type to substitute the required type in the context of function and interface.
-
C# Functional Programming In-Depth (10) Query Expression
C# 3.0 introduces query expression, a SQL-like query syntactic sugar for query methods composition.
-
C# Functional Programming In-Depth (9) Function Composition and Chaining
As demonstrated in the introduction chapter, in object-oriented programming, program is modelled as objects, and object composition is very common, which combines simple objects to more complex objects. In functional programming, program is modelled as functions, function composition is emphasized, which combines simple functions to build more complex functions. LINQ query is composition of quelop.
-
C# Functional Programming In-Depth (8) Higher-order Function, Currying and First Class Function
The delegate chapter and other previous chapters have demonstrated that in C#, function supports many operations that are available for object. This chapter discusses one more aspect, higher-order function, and how it and other functional features make function the first-class citizen in C# language.
-
C# Functional Programming In-Depth (7) Expression Tree: Function as Data
C# lambda expression is a powerful syntactic sugar. Besides representing anonymous function, the same syntax can also represent expression tree. An expression tree is an immutable tree data structure that represents structure of code. For example:
-
C# Functional Programming In-Depth (6) Anonymous Function and Lambda Expression
Besides named function, C# also supports anonymous function, represented by anonymous method or lambda expression with no function name at design time. Lambda expression can also represent expression tree, This chapter discusses lambda expression as a functional feature of C# language. Lambda expression is also the core concept of lambda calculus, where functional programming originates. It is revisited in the Lambda Calculus chapters.
-
C# functional programming in-depth (3) Local Function and Closure
The previous chapter discussed named function. There is one more special kind of named function. local function. Local function can be nested in another function, and it supports an important feature closure, the ability access variable outside the local function itself.
-
C# functional programming in-depth (2) Named function and function polymorphism
This chapter starts the deep dive in functional programming with C#. C# has named function and anonymous function. In C#, the most intuitive functions are method members of class and structure, including static method, instance method, and extension method, etc. These method members are defined with names at design time and can be called by name, so they are named functions. Some other method-like members, including static constructor, constructor, finalizer, conversion operator, operator overload, property, indexer, event accessor, are also named functions, with function name generated at compiled time. This chapter discusses named functions in C#, how these named functions are defined compiled, and called, as well as their polymorphisms. A special named function, local function, is discussed in next chapter.
-
C# functional programming in-depth (1) C# language basics
The previous chapter demonstrates that C# is a standardized, cross-platform, and multi-paradigm language, and gives an overview that C# is very functional with rich features, including LINQ, a unified functional programming model to work with different data domains. Since this chapter, we dive into C# coding.
-
Understanding LINQ to SQL (11) Performance
LINQ to SQL has a lot of great features like
- strong typing
- query compilation
- deferred execution
- declarative paradigm
etc., which are very productive. Of course, these cannot be free, and one price is the performance.
-
Microsoft Most Valuable Professional Kit Unboxing
I am very happy to receive the Microsoft Most Valuable Professional Kit:
-
Understanding C# Features (9) Partial Method
[LINQ via C#] - [C# Features]
-
Understanding C# Features (10) Query Expression
[LINQ via C#] - [C# Features]
-
Understanding C# Features (5) Lambda Expression, Anonymous Function and Expression Tree
[LINQ via C#] - [C# Features]
-
Understanding C# Features (4) Extension Method
[LINQ via C#] - [C# Features]
-
Understanding C# 3.0 Features (4) Anonymous Type
-
Understanding C# Features (3) Implicit Type and Immutable Anonymous Type
[LINQ via C#] - [C# Features]