Hi,
I know Julia isn't OO by design, but is there any reason it couldn't be? Consider following code:
str = "some test"
beginswith(str, "some")
I know that with defining extra methods for
colon we can get:
But wouldn't it be nicer if Julia actually tried to resolve this as well:
str.beginswith("some") # === beginswith(str, "some")
In theory this would let us have some dynamic properties (accessors) on objects, i.e:
str.length # === length(str)
Or even setters:
str.length = 3 # === setlength(str, 3)
Of course only if referenced field does NOT exists, so if does not charm existing codebase.
Finally a "dream come true would" to be able to define type specific methods using following notation:
function String.mysanitize
this.lowercase
end
# equvalent
function mysanitize(s::String)
lowercase(s)
end
This would make Julia friendly for OO programmers, and IMHO making programs more readable.