Constructors that fail when called without new are a potential problem, and three solutions we can use are, respectively, auto-instantiation, overloading the constructor, or killing such calls with fire.

Here's the rest of the article.

]]>Constructors that fail when called without new are a potential problem, and three solutions we can use are, respectively, auto-instantiation, overloading the constructor, or killing such calls with fire.

Here's the rest of the article.

]]>`begin`

lookalike in ES6, we can take advantage of the fact that in JavaScript arguments are evaluated from left to right. This leads to:
```
const begin = (...args) => args[args.length - 1];
```

We can therefore replicate SICP's `make-withdraw`

procedure as:

`const makeWithdraw = bal =>`

]]>`begin`

lookalike in ES6, we can take advantage of the fact that in JavaScript arguments are evaluated from left to right. This leads to:
```
const begin = (...args) => args[args.length - 1];
```

We can therefore replicate SICP's `make-withdraw`

procedure as:

```
const makeWithdraw = bal =>
amount => bal >= amount ? begin(bal = bal - amount, bal)
: "Insufficient founds"
```

]]>`let`

expressions, such as
```
(let ((x 3) (y 5)) (+ x y))
```

is to use ES6 default parameters:

```
((x = 3, y = 5) => x + y)()
```

It is possible to go one step further by defining an auxiliary `let_`

function as:

`const let_ = f => f(`

]]>`let`

expressions, such as
```
(let ((x 3) (y 5)) (+ x y))
```

is to use ES6 default parameters:

```
((x = 3, y = 5) => x + y)()
```

It is possible to go one step further by defining an auxiliary `let_`

function as:

```
const let_ = f => f();
```

This allows rewriting the previous function application as:

```
let_((x = 3, y = 5) => x + y);
```

Definitely not the most idiomatic thing to do, though :-)

]]>"Unit tests prove that a solution works in a particular way, rather than asserting that it solves a particular problem."

(J. Humble et al.)

]]>"Unit tests prove that a solution works in a particular way, rather than asserting that it solves a particular problem."

(J. Humble et al.)

]]>"Pascal and C are special-purpose languages for manipulating the registers and memory."

(P. Norvig)

]]>"Pascal and C are special-purpose languages for manipulating the registers and memory."

(P. Norvig)

]]>"We do not develop the domain. The domain is some realm of know-how of the business we are working in. What we design and implement is a model of a domain."

(V. Vernon)

]]>"We do not develop the domain. The domain is some realm of know-how of the business we are working in. What we design and implement is a model of a domain."

(V. Vernon)

]]>"Naming is perhaps the most powerful abstracting notion we have, in any language, for it allows any complex to be reduced for linguistic purposes to a primitive atom."

(G. L. Steele Jr.)

]]>"Naming is perhaps the most powerful abstracting notion we have, in any language, for it allows any complex to be reduced for linguistic purposes to a primitive atom."

(G. L. Steele Jr.)

]]>"Mathematical induction proves that we can climb as high as we like on a ladder, by proving that we can climb onto the bottom rung (the basis) and that from each rung we can climb up to the next one (the induction)."

(Concrete Mathematics 2nd ed.)

]]>"Mathematical induction proves that we can climb as high as we like on a ladder, by proving that we can climb onto the bottom rung (the basis) and that from each rung we can climb up to the next one (the induction)."

(Concrete Mathematics 2nd ed.)

]]>"If we look at mathematics, it has been greatly driven by overloading. Extensions of a notion of numbers from natural numbers to integers, to rational numbers, to Gaussian integers, to p-adic numbers, etc., are examples of overloading. One can easily guess things without knowing exact definitions. If I see an

]]>"If we look at mathematics, it has been greatly driven by overloading. Extensions of a notion of numbers from natural numbers to integers, to rational numbers, to Gaussian integers, to p-adic numbers, etc., are examples of overloading. One can easily guess things without knowing exact definitions. If I see an expression that uses both addition and
multiplication, I assume distributivity. If I see less-than and addition, I assume that if `a < b`

then `a + c < b + c`

(I seldom add uncountable cardinals).

**Overloading allows us to carry knowledge from one type to another.**"

(A. Stepanov)

]]>"When dealing with "creational" use cases, try to find another aggregate or factory you can move that responsibility to. Sometimes the factory is just a static method (good for "context"/"intent" capturing), sometimes it's an instance method of another aggregate (good place for "data" inheritance), sometimes it's an explicit factory

]]>"When dealing with "creational" use cases, try to find another aggregate or factory you can move that responsibility to. Sometimes the factory is just a static method (good for "context"/"intent" capturing), sometimes it's an instance method of another aggregate (good place for "data" inheritance), sometimes it's an explicit factory object (good place for "complex" creation logic)."

]]>The goal of this tutorial is to provide enough knowledge and ability on Scheme programming language to read SICP, which is one of the best text book on computer science. The book uses Scheme to explain subjects.

]]>The goal of this tutorial is to provide enough knowledge and ability on Scheme programming language to read SICP, which is one of the best text book on computer science. The book uses Scheme to explain subjects.

]]>“The requirements of a polymorphic type, by definition, come from where you use the type, not from the type itself.”

]]>"When I use inheritence, I build the use of my object into my object. On the contrary, what I want to do is separate the use of my

“The requirements of a polymorphic type, by definition, come from where you use the type, not from the type itself.”

]]>"When I use inheritence, I build the use of my object into my object. On the contrary, what I want to do is separate the use of my object from the object itself.

There are no polymorphic types, only a polymorphic use of similar types."

"An **effect** is the structural information of a `Functor`

, i.e., the part that is not parametric.

The state value in `State`

, failure in `Maybe`

and `Either`

, the number of elements in `[]`

, and – of course – arbitrary external side effects in `IO`

."

"An **effect** is the structural information of a `Functor`

, i.e., the part that is not parametric.

The state value in `State`

, failure in `Maybe`

and `Either`

, the number of elements in `[]`

, and – of course – arbitrary external side effects in `IO`

."

"There is a considerable difference between a mathematician’s view of the world and a computer scientist’s. To a mathematician all structures are static: they have always been and will always be; the only time dependence is that we just have not discovered them all yet. The computer scientist

]]>"There is a considerable difference between a mathematician’s view of the world and a computer scientist’s. To a mathematician all structures are static: they have always been and will always be; the only time dependence is that we just have not discovered them all yet. The computer scientist is concerned with (and fascinated by) the continuous creation, combination, separation and destruction of structures: time is of the essence. In the hands of a mathematician, the Peano axioms create the integers without reference to time, but if a computer scientist uses them to implement integer addition, he finds they describe a very slow process, which is why he will be looking for a more efficient approach."

(Dick Grune and Ceriel J. H. Jacobs)

]]>Instead, let us try to delineate the category in which objects are C++ types. In such a category, morphisms are *metafunctions*

Instead, let us try to delineate the category in which objects are C++ types. In such a category, morphisms are *metafunctions* rather than ordinary functions. Thus, the identity morphisms are all representable via the following `id`

metafunction:

```
template <typename T>
using id = T;
```

We can introduce other morphisms in a similar fashion. For instance, we can come up a morphism that maps from some type `T`

to `T*`

:

```
template <typename T>
using add_pointer = T*;
```

Morphisms can be composed through a correspoding `compose`

operator, implemented as:

```
template <
template <typename> class f,
template <typename> class g
>
struct compose {
template <typename T>
using apply = g<f<T>>;
};
```

With all the elements in place, we are now in the condition to put our category at work. As an example, we can check the identity law:

```
// Identity laws
using int_ptrL = compose<id, add_pointer>::apply<int>;
using int_ptrR = compose<add_pointer, id>::apply<int>;
static_assert(std::is_same_v<int_ptrL, int_ptrR>);
```

]]>