Afzal Najam
01/21/2021, 4:47 PMMatteo Mirk
01/21/2021, 4:52 PMAfzal Najam
01/21/2021, 4:53 PMNir
01/21/2021, 4:54 PMNir
01/21/2021, 4:54 PMAfzal Najam
01/21/2021, 4:54 PMNir
01/21/2021, 4:59 PMTyler Hodgkins
01/21/2021, 7:53 PMTyler Hodgkins
01/21/2021, 7:55 PMNir
01/21/2021, 9:18 PMNir
01/21/2021, 9:18 PMNir
01/21/2021, 9:19 PMNir
01/21/2021, 9:22 PMNir
01/21/2021, 9:22 PMAfzal Najam
01/21/2021, 9:24 PMNir
01/21/2021, 9:30 PMAfzal Najam
01/21/2021, 9:30 PMNir
01/21/2021, 9:31 PMAfzal Najam
01/21/2021, 9:31 PMNir
01/21/2021, 9:31 PMAfzal Najam
01/21/2021, 9:31 PMNir
01/21/2021, 9:31 PMAfzal Najam
01/21/2021, 9:32 PMNir
01/21/2021, 9:33 PMstatic
Afzal Najam
01/21/2021, 9:34 PMNir
01/21/2021, 9:34 PMNir
01/21/2021, 9:35 PMstatic
doesn't create an object. and the whole point of namespace
inside a class is to have functions accessed via <classname>.foo without having any associated static object instanceAfzal Najam
01/21/2021, 9:36 PMNir
01/21/2021, 9:36 PMnamespace vs static is starting to feel like quacking like a duck but refusing to admit that you do, in fact, have a duck
Nir
01/21/2021, 9:37 PMAfzal Najam
01/21/2021, 9:37 PMNir
01/21/2021, 9:37 PMNir
01/21/2021, 9:37 PMAfzal Najam
01/21/2021, 9:38 PMTyler Hodgkins
01/21/2021, 9:38 PMstatic
keyword that represents a method defined inside of a class that isn’t actually a method, it’s now just a non-contextual function. That static
keyword can’t be used outside of a class (because it’s unnecessary).Nir
01/21/2021, 9:38 PMNir
01/21/2021, 9:38 PMTyler Hodgkins
01/21/2021, 9:38 PMstatic
when the concept they came up with (namespace
) can represent the same thing?Nir
01/21/2021, 9:38 PMNir
01/21/2021, 9:38 PMNir
01/21/2021, 9:39 PMTyler Hodgkins
01/21/2021, 9:39 PMstatic
is arbitrary, namespace
is generalizable.Nir
01/21/2021, 9:39 PMTyler Hodgkins
01/21/2021, 9:40 PMNir
01/21/2021, 9:40 PMNir
01/21/2021, 9:41 PMNir
01/21/2021, 9:42 PMTyler Hodgkins
01/21/2021, 9:42 PMNir
01/21/2021, 9:43 PMNir
01/21/2021, 9:43 PMNir
01/21/2021, 9:45 PMTyler Hodgkins
01/21/2021, 9:46 PMNir
01/21/2021, 9:46 PMNir
01/21/2021, 9:46 PMNir
01/21/2021, 9:46 PMTyler Hodgkins
01/21/2021, 9:47 PMNir
01/21/2021, 9:47 PMNir
01/21/2021, 9:47 PMNir
01/21/2021, 9:48 PMNir
01/21/2021, 9:48 PMimport foo
and then foo.bar
, or even import foo as f
and f.bar
Nir
01/21/2021, 9:48 PMAfzal Najam
01/21/2021, 9:50 PMNir
01/21/2021, 9:52 PMNir
01/21/2021, 9:53 PMNir
01/21/2021, 9:54 PMimport x.y.bar
and then calling bar
Nir
01/21/2021, 9:57 PMnapperley
01/22/2021, 1:36 AMelizarov
01/22/2021, 8:01 AM@Nir I guess I'd like to understand, to start with, why people want to be able to write <whatever>.bar to begin with instead of justPeople want it whenand then callingimport x.y.bar
bar
bar
is a short word that would be ambiguous without a qualifier. Just one example (there are tons more in libs out there). Take a look at <http://Dispatchers.IO|Dispatchers.IO>
from coroutines. You don't want to write just IO
as it is too short and lacks context. You could solve it by giving it a longer name with a prefix like DispatchersIO
. But this way you cannot logically group all the dispatchers, all you'll have is their common name prefix.trathschlag
01/22/2021, 8:39 AMelizarov
01/22/2021, 8:41 AMelizarov
01/22/2021, 8:42 AMmodule
for this concept in Kotiln, though. It will be too confusing in the Kotlin ecosystem.Nir
01/22/2021, 1:06 PMNir
01/22/2021, 1:06 PMNir
01/22/2021, 1:07 PMNir
01/22/2021, 1:09 PMelizarov
01/22/2021, 1:32 PMelizarov
01/22/2021, 1:34 PMMatteo Mirk
01/22/2021, 1:53 PMNir
01/22/2021, 3:02 PMNir
01/22/2021, 3:02 PMNir
01/22/2021, 3:03 PMimport kotlin.collections.List as foo
fun main() {
val x: foo<Int> = listOf(1,2,3)
}
Nir
01/22/2021, 3:03 PMNir
01/22/2021, 3:03 PMNir
01/22/2021, 3:03 PMNir
01/22/2021, 3:05 PMimport kotlin.collections
(without the as
) seems to solve one of the two use cases. But there's still the other use case, where people really badly want to qualify using the class name. I'm not sure how much separate value that has.elizarov
01/22/2021, 3:10 PMNir
01/22/2021, 3:12 PMNir
01/22/2021, 3:14 PMimport foo
and use foo.bar
, or from foo import bar
, renaming imports are relatively rare, or sometimes they are renamed to _
versions (because pythons imports are transitive, unlike kotlin), and there are some standard aliases like import numpy as np
Nir
01/22/2021, 3:14 PMNir
01/22/2021, 3:16 PMelizarov
01/22/2021, 3:16 PMNir
01/22/2021, 3:18 PMelizarov
01/22/2021, 3:19 PM<http://Dispatchers.IO|Dispatchers.IO>
, Delegates.notNull()
etc. Unfortunately, right now we have to abuse object
for that (which we don't need)Nir
01/22/2021, 3:20 PMimport kotlin.collections
, it's a miniscule change and lets designers do what they want; a second step would be allowing a local "sub-package"Nir
01/22/2021, 3:21 PMpackage top
...
local package sub {
...
}
And then
import top.*
sub.whatever
Or
import top.sub
sub.whatever
Nir
01/22/2021, 3:23 PMAfzal Najam
01/22/2021, 9:21 PM