Arc Forumnew | comments | leaders | submitlogin
2 points by Jesin 6131 days ago | link | parent

I think I am going to say here that from the little I have seen of Factor (http://factorcode.org/) I really like its object system. Method calls look like normal words, but they work for anything that implements a method for that word. I'm going to use sequences as an example. Arrays, quotations (code blocks) and integers all implement the sequence protocol, so for example:

  { 2 7 1 } 3 add { 6 5 } append
makes the array { 2 7 1 3 6 5 }

  [ foo bar ] \ baz add [ foobaz barbaz ] append
makes the quotation [ foo bar baz foobaz barbaz ]

  4 7 add { "bar" "baz" } append 3 append
makes the array { 0 1 2 3 7 "bar" "baz" 0 1 2 }.

I think any object system we put in the language should include the ability to create types that define their own versions of functions like join, and the ability to inherit from other types.

This seems to fit well with the following design philosophy:

Can I? Yes.

Do I have to? No.

That is, it allows you to think about type definitions and OOP, but if you don't want to, you can still use types that you or other people have defined as if they were built in, without having to think about the OOP.