A subtle difference between a map of functions and a Python class is that
the class has implicit "self" or "this".  Otherwise, these are semantically
the same.  Well, ignoring that Clojure maps are immutable.

In fact, C++ compilers compile methods by inserting a first "this" argument
and mangling the name.  Virtual methods (ones which can be overridden) are
collected into what is effectively a map attached to the instance.

On Tue, Mar 31, 2020 at 4:41 AM Dieter Van Eessen <
dieter.van.ees...@gmail.com> wrote:

> Hello,
>
> I've got a clojure and a python piece of code. Both seem to create what
> can be considered an instance of a class. Wherein lies the conceptual
> difference?
>
> Python:
> class MYCLASS():
>     def __init__(self, x):
>           self.x = x
>     def MYMETHOD(self):
>          ...
>
> def MYFUNCTION():
>     lol = MYCLASS()
>
> Clojure:
> (defn MYCLASS [x]
>      {:x [x]
>       :MYMETHOD (fn [] (MYCLASS ...))})
>
> (let [lol (MYCLASS ...)])
>
> I know its not valid code, but I hope you see what I'm aiming at: isn't
> using a map with functions in it just the same as a class?
> Or is only the user interface of the language conceptually equal, while
> the underlying plumbing is completely different?
> If this is the case, wherein lies the major differences?
>
> If one could simply point me in the right direction, I'd already be very
> pleased. Most literature I've read so far only explains clojure can be used
> this way, but never focuses deeper on the subject.
>
> kind regards,
> Dieter
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/clojure/49cd26ca-48ae-48b4-a5ab-b0f7c711b77e%40googlegroups.com
> <https://groups.google.com/d/msgid/clojure/49cd26ca-48ae-48b4-a5ab-b0f7c711b77e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/CAB6_SoYCTeKi2teO%3DbgyEB-Vu3C-fCGpX6T%3DXZB8ApmDP-c8vA%40mail.gmail.com.

Reply via email to