Brother Bill (14) [Avatar] Offline
#1
From C# and Java, an interface is a set of method signatures that have to be implemented by a host class.
When I look at the example, it appears that interface Expr is an empty interface.
And then both Num and Sum implement Expr, which has nothing to be implemented.

Why are we doing this? This is very confusing.

The other possibility is that Expr provides two methods that need to be implemented by a host class.
I think that is what you mean.

What is throwing me is that there are no braces wrapping the signatures of Num and Sum.
How do I know when the interface ends?

The syntax is quite strange for someone from C# or Java.
Additional commentary about this would be helpful.

Would Expr be in its own file?

As you can see, this example is very confusing to me.

-----

Suggestions:
1. If Expr is in fact an empty interface, explain the value of an empty interface and why it is used.
Dmitry Jemerov (39) [Avatar] Offline
#2
Thanks for the feedback! In the example, `Expr` is indeed an interface which does not define any methods. Such interfaces exist in other languages as well, and are called marker interfaces: https://en.wikipedia.org/wiki/Marker_interface_pattern

We'll update the text of the book to make this point clearer.
408399 (15) [Avatar] Offline
#3
Hi, Bill,
In Java, a very common example of a Marker Interface is Serializable.