Re: protocols and overloading

2013-12-30 Thread Sean Corfield
On Mon, Dec 30, 2013 at 11:30 AM, Cedric Greevey wrote: > On Mon, Dec 30, 2013 at 12:59 PM, Massimiliano Tomassoli >> A class must support encapsulation, inheritance and polymorphism. If it >> doesn't, then it isn't a class. The same way, a method is a function that >> belongs to a class and can b

Re: protocols and overloading

2013-12-30 Thread Cedric Greevey
On Mon, Dec 30, 2013 at 12:59 PM, Massimiliano Tomassoli wrote: > On Monday, December 30, 2013 6:31:52 PM UTC+1, Cedric Greevey wrote: > >> On Mon, Dec 30, 2013 at 12:30 PM, Massimiliano Tomassoli < >> kiuh...@gmail.com> wrote: >> >>> On Sunday, December 29, 2013 11:30:16 PM UTC+1, Cedric Greevey

Re: protocols and overloading

2013-12-30 Thread Cedric Greevey
On Mon, Dec 30, 2013 at 12:45 PM, Massimiliano Tomassoli wrote: > On Monday, December 30, 2013 6:27:05 PM UTC+1, Cedric Greevey wrote: > >> On Mon, Dec 30, 2013 at 12:13 PM, Massimiliano Tomassoli < >> kiuh...@gmail.com> wrote: >> >>> On Sunday, December 29, 2013 10:11:47 PM UTC+1, tbc++ wrote: >

Re: protocols and overloading

2013-12-30 Thread Gary Trakhman
There's been a trend against overuse of inheritance, first with java removing multiple-inheritance and the various private/protected nuanced inheritances, then generally accepted advice like 'prefer composition over inheritance'. Some people were still feeling the pain, and some of those are now u

Re: protocols and overloading

2013-12-30 Thread Massimiliano Tomassoli
On Monday, December 30, 2013 6:46:13 PM UTC+1, tbc++ wrote: > > And what Cedric says is correct, encapsulation is rarely a good thing, and > inheritance is overrated. > That's your opinion, not a fact. By saying that something is overrated you're just admitting that many people don't agree with

Re: protocols and overloading

2013-12-30 Thread Timothy Baldridge
Ok, so if we take that definition of classes and methods, then what I'm saying is that the expression problem can be solved much easier via single dispatch polymorphic functions, and datatypes. At that point it's just a question of where the vtable is stored. In C++ it's in the object, in Clojure,

Re: protocols and overloading

2013-12-30 Thread Massimiliano Tomassoli
On Monday, December 30, 2013 6:31:52 PM UTC+1, Cedric Greevey wrote: > > On Mon, Dec 30, 2013 at 12:30 PM, Massimiliano Tomassoli < > kiuh...@gmail.com > wrote: > >> On Sunday, December 29, 2013 11:30:16 PM UTC+1, Cedric Greevey wrote: >> >>> On Sun, Dec 29, 2013 at 4:11 PM, Timothy Baldridge >>>

Re: protocols and overloading

2013-12-30 Thread Timothy Baldridge
" If the Expression Problem consists in extending classes then non-OOP languages must be excluded because they don't have classes." No offense intended, but that is an incredibly wrong statement. Let's look up the official definition of the expression problem (via wikipedia): "The goal is to defin

Re: protocols and overloading

2013-12-30 Thread Timothy Baldridge
C# extension methods are not polymorphic either. For example, casting a object to a parent type will cause a different extension method to be run. This is not the case in normal polymorphism, or for protocols (Clojure is a dynamic language, so casting doesn't exist anyways). You're right, you can

Re: protocols and overloading

2013-12-30 Thread Massimiliano Tomassoli
On Monday, December 30, 2013 6:27:05 PM UTC+1, Cedric Greevey wrote: > > On Mon, Dec 30, 2013 at 12:13 PM, Massimiliano Tomassoli < > kiuh...@gmail.com > wrote: > >> On Sunday, December 29, 2013 10:11:47 PM UTC+1, tbc++ wrote: >>> >>> Not mentioned in Cedric's post are two other important things: >

Re: protocols and overloading

2013-12-30 Thread Cedric Greevey
On Mon, Dec 30, 2013 at 12:30 PM, Massimiliano Tomassoli wrote: > On Sunday, December 29, 2013 11:30:16 PM UTC+1, Cedric Greevey wrote: > >> On Sun, Dec 29, 2013 at 4:11 PM, Timothy Baldridge wrote: >> >>> Not mentioned in Cedric's post are two other important things: >>> >>> Protocols can be ext

Re: protocols and overloading

2013-12-30 Thread Massimiliano Tomassoli
On Sunday, December 29, 2013 11:30:16 PM UTC+1, Cedric Greevey wrote: > > On Sun, Dec 29, 2013 at 4:11 PM, Timothy Baldridge > > > wrote: > >> Not mentioned in Cedric's post are two other important things: >> >> Protocols can be extended to existing types. >> > > These are important for the Expre

Re: protocols and overloading

2013-12-30 Thread Cedric Greevey
On Mon, Dec 30, 2013 at 12:13 PM, Massimiliano Tomassoli wrote: > On Sunday, December 29, 2013 10:11:47 PM UTC+1, tbc++ wrote: >> >> Not mentioned in Cedric's post are two other important things: >> >> Protocols can be extended to existing types. For example: >> >> (defprotocol IType >> (type-a

Re: protocols and overloading

2013-12-30 Thread Massimiliano Tomassoli
On Sunday, December 29, 2013 10:11:47 PM UTC+1, tbc++ wrote: > > Not mentioned in Cedric's post are two other important things: > > Protocols can be extended to existing types. For example: > > (defprotocol IType > (type-as-string [x])) > > (extend-protocol IType > String > (type-as-string [x

Re: protocols and overloading

2013-12-29 Thread Cedric Greevey
Yeah, it was sometime in the 90s. The only workaround I could think of was maybe to create a single compilation unit for template use, and there derive a trivial subclass of each used template specialization, then use that subclass elsewhere in lieu of the template. Needless to say, not a solution

Re: protocols and overloading

2013-12-29 Thread Sean Corfield
That must have been a long time ago? That problem was solved well before I left the C++ committee in '99 and gcc was normally pretty good at tracking the emerging standard at the time... But, yes, the template compilation model and it's impact on linking modules that specialized the same template

Re: protocols and overloading

2013-12-29 Thread Cedric Greevey
On Sun, Dec 29, 2013 at 4:11 PM, Timothy Baldridge wrote: > Not mentioned in Cedric's post are two other important things: > > Protocols can be extended to existing types. > These are important for the Expression Problem, but not for the OP's query as originally stated, which simply asked for the

Re: protocols and overloading

2013-12-29 Thread Mark Engelberg
The expression problem is about what kinds of additions and extensions you can easily make *without modifying or recompiling the existing codebase.* -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googl

Re: protocols and overloading

2013-12-29 Thread Timothy Baldridge
Not mentioned in Cedric's post are two other important things: Protocols can be extended to existing types. For example: (defprotocol IType (type-as-string [x])) (extend-protocol IType String (type-as-string [x] "string") Integer (type-as-string [x] "integer")) => (type-as-string 42)

Re: protocols and overloading

2013-12-29 Thread Massimiliano Tomassoli
On Sunday, December 29, 2013 7:05:28 PM UTC+1, Cedric Greevey wrote: > > On Sun, Dec 29, 2013 at 12:27 PM, Massimiliano Tomassoli < > kiuh...@gmail.com > wrote: > >> What's the difference between protocols and simple overloading? >> > > Dynamic dispatch. Overloading uses just the static type for di

Re: protocols and overloading

2013-12-29 Thread Cedric Greevey
On Sun, Dec 29, 2013 at 12:27 PM, Massimiliano Tomassoli wrote: > What's the difference between protocols and simple overloading? > Dynamic dispatch. Overloading uses just the static type for dispatch, so this Java code: aBase = new Base(); aDerived = new Derived(); aBase2 = aDerived; something