Vincent @vinyll 22:15 I find this confusing:
require "athena"
class ExampleController < ART::Controller
ART exists in athena, but how can you figure where it comes from when requiring muliple files? Also how can you avoid names collision?
Scott Boggs @dscottboggs 22:16 where it comes from
What do you mean by this?
how can you avoid names collision?
By namespacing everything
George Dietrich @Blacksmoke16 22:17 ART is an alias Athena::Routing
Vincent Agnano @vinyll 22:17
How would you know that ART
is declared in athena
?
George Dietrich @Blacksmoke16 22:17 less typing
Scott Boggs @dscottboggs 22:17 the docs
George Dietrich @Blacksmoke16 22:17 read the API docs? yea thats kinda a problem with any shard, you wouldnt know the types that are exposed from that shard w/o looking at api or source
Vincent Agnano @vinyll 22:18 I mean in Python one would do from athena import ART and the code would be explicit. Here, readiing the code, it seems like it comes out of nowhere. Changing language is changing paradigms; so I'm learning to adapt ;)
George Dietrich @Blacksmoke16 22:18 i would love to have something like that, but alas it doesnt exist
Scott Boggs @dscottboggs 22:19 name collision is not an error in Crystal -- if you, do
def foo
"a"
end
def foo
"b"
end
Calling foo() would return "b". If you do
class Ex
def a
"a"
end
end
class Ex
def b
"b"
end
end
Both #a
and #b
will be defined as members of Ex
, rather than an error being thrown
this is a big change if you're used to python (even though it's technically possible to do at least the latter example in python, the way to do it isn't obvious)
From IRC (bridge bot) @FromIRC 22:21 unlearning python is such a pleasant experience, wish i could do it again that language is so broken on so many levels :<
Vincent Agnano @vinyll 22:21 Right, I see the confusion and collision. Is there a benefit, flexibility or other interest with this paradigm?
George Dietrich @Blacksmoke16 22:21 i have thought about using private aliases to avoid large namespace names in code like a pseudo import system, but 🤷 prob just is what Ruby does 🤷 is how it came to be
Scott Boggs @dscottboggs 22:40 yes exactly, firstly it was how ruby did it