Hello!
I've been using Julia for a half a year at the moment and I really like it. In the past I've been using mainly Python, C++ and JavaScript in which objects are necessary. This morning me and my friend Jukka started tinkering with Julia: we were wondering can you use JavaScript syntax. After an hour we noticed that we had created a naive object in JavaScript syntax. Since we had already created a object, why not use Python class syntax: a constructor and dot syntax for referring functions and variables. So, here's a funny workaround for object :)
julia> type Object
get_a
set_a
end
julia> Object(n) = Object(() -> n["get_a"](),(m) -> n["set_a"](m))
Object
julia> Object() = Object((() -> begin
private_data = Dict("a" => 1)
public_data = Dict()
methods = Dict{ASCIIString, Any}()
methods["get_a"] = () -> private_data["a"]
methods["set_a"] = (k) -> (private_data["a"] = k)
methods["data"] = public_data
methods
end)())
Object
julia> class_1 = Object()
Object((anonymous function),(anonymous function))
julia> class_2 = Object()
Object((anonymous function),(anonymous function))
julia> class_1.get_a()
1
julia> class_1.set_a(10)
10
julia> class_1.get_a()
10
not sure if someone has already invented this but in PyPlot I guess same has been archived with a Dict. Still, all fun and games.