https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
language-proposals
  • d

    dmitry.petrov

    03/16/2017, 2:35 PM
    We are going to start from array literals in annotations in 1.2, and build full design on top of that.
    b
    i
    • 3
    • 3
  • o

    okaymak

    03/16/2017, 2:38 PM
    ( . )( . )
    👙 4
    m
    • 2
    • 1
  • m

    mg6maciej

    03/16/2017, 2:39 PM
    Are there any plans to support trailing commas?
    ➕ 4
    k
    e
    a
    • 4
    • 10
  • k

    kirillrakhman

    03/17/2017, 6:49 PM
    @adeln if you're willing to trade elegance for performance, you could do
    var beforeFrame: View? = null
      var beforeImg: ImageView? = null
    
      var afterFrame: View? = null
      var afterImg: ImageView? = null
    
      val v = linearLayout {
    
        layoutParams = ViewGroup.LayoutParams(wrapContent, matchParent)
    
        beforeFrame =
            frameLayout {
    
              beforeImg =
                  imageView {
    
                  }
            }.lparams()
    
        afterFrame =
            frameLayout {
    
              afterImg =
                  imageView {
    
                  }
            }.lparams()
      }
    
      return PairedPhotoPreviewHolder(v, beforeFrame!!, beforeImg!!, afterFrame!!, afterImg!!)
    a
    • 2
    • 1
  • o

    okaymak

    03/18/2017, 9:25 PM
    is there any reason Kotlin doesn’t allow a body inside an annotation class?
    l
    d
    • 3
    • 3
  • b

    benleggiero

    03/21/2017, 12:11 AM
    Seems impossible on the JVM
    v
    • 2
    • 2
  • b

    beholder

    03/21/2017, 5:05 PM
    Is it possible to simplify delegated properties mechanics to not use
    KProperty
    , but just
    String
    for property name?
    👍 1
    l
    • 2
    • 2
  • m

    miha-x64

    03/21/2017, 7:53 PM
    This channel is for certain proposals, not discussion. If you want just to add some names to properties, you can create annotations that will hold them.
    v
    o
    • 3
    • 2
  • b

    benleggiero

    03/21/2017, 11:45 PM
    Proposal: Make
    -
    a part of number literals, so that calls like
    -1L.dec()
    are the same as
    (-1L).dec()
    instead of
    -(1L.dec())
    v
    m
    • 3
    • 8
  • b

    benleggiero

    03/22/2017, 12:53 AM
    Yeah... 1 point to Swift I suppose.
    m
    • 2
    • 2
  • r

    rrader

    03/24/2017, 2:08 PM
    a proposal for collection literal val array: Array<Long> = [1, 2, 3] val list: List<Long> = [1, 2, 3] val map: Map<String, Long> = ["a" -> 1, "b" -> 2] so, if type is specified we can use [ ... ] literal
    👍 3
    b
    v
    • 3
    • 3
  • m

    mg6maciej

    03/24/2017, 7:23 PM
    I'd like type aliases to be strongly typed, so you cannot pass differently typed value of the same type.
    😶 1
    👍 4
    e
    o
    • 3
    • 3
  • m

    mg6maciej

    03/24/2017, 7:25 PM
    typealias UserId = String
    class User(val id: UserId)
    val myString: String = "blabla"
    User(myString) // wouldn't compile
    b
    s
    • 3
    • 11
  • j

    johnl

    03/25/2017, 10:49 AM
    Please intialize all optionals to null
    m
    b
    • 3
    • 2
  • e

    elect

    03/26/2017, 8:29 PM
    it'd nice to have
    forEachIndexed
    offering immediately
    i, it
    b
    m
    • 3
    • 9
  • d

    dmitry.petrov

    03/27/2017, 6:18 AM
    The main question about "strongly typed type aliases", aka "newtype in Kotlin": how would you actually use it, and when you figure out how, how is that different from value types 🙂 ?
    i
    • 2
    • 1
  • d

    dmitry.petrov

    03/27/2017, 11:05 AM
    We could create some special abstract method for that constructor, and implement it in subclasses for each overridden constructor, but how's that different from an abstract factory method mentioned above?
    b
    • 2
    • 1
  • l

    louiscad

    03/27/2017, 3:45 PM
    Hi, I discovered while IntelliJ is fine with nested objects (
    object
    declared in an
    object
    ) extending an
    inner class
    of a superclass of the enclosing object, the compiler fails when you do this. I had to replace my
    inner class
    with a constructor property instead, while the extended inner class would have made it implicit, allowing me to strip the extra val constructor parameter
    d
    • 2
    • 2
  • c

    cedric

    03/27/2017, 5:21 PM
    @benleggiero My immediate reaction was similar to @dmitry.petrov: it’s going to be hard to make a case for this that is not adequately captured by abstract factories. C# offers this concept, so that you can call
    new
    on a type parameter, but I’ve always found it unnecessary since you can just as well pass a lambda factory method.
    b
    • 2
    • 1
  • j

    johnl

    03/28/2017, 11:41 AM
    data class ApiBuyer ( var id: Int? = null, var customerId: String? = null, var firstName: String? = null, var lastName: String? = null, var addressLine1: String? = null, var addressLine2: String? = null, var city: String? = null, var state: String? = null, var postalCode: String? = null, var country: String? = null, var email: String? = null, var phone: String? = null, var password: String? = null, var status: String? = null, var tripIdPendingRating: Int? = null, var profileImageUrl: String? = null, var pushToken: String? = null, var rating: String? = null, var ratings: Int? = null, var isAdult: Boolean? = null, var defaultToApplePay: Boolean? = null, var applePayCardId: Boolean? = null, var defaultTipPercent: Int? = null, var promoCode: String? = null, var tosAcceptedVersion: String? = null, var createdAt: Date? = null, var updatedAt: Date? = null, var version: Int? = null ) { override fun equals(other: Any?): Boolean { return super.equals(other) } override fun hashCode(): Int { return super.hashCode() } }
    😱 6
    l
    m
    +2
    • 5
    • 16
  • l

    louiscad

    03/28/2017, 12:45 PM
    Hi, My use case is quite complex (a RecyclerView.Adapter for an Android app), but basically, I'd like smart casts to apply to
    check(…)
    and
    require(…)
    stdlib methods. What do you think?
    🤔 1
    i
    • 2
    • 1
  • b

    benleggiero

    03/28/2017, 1:10 PM
    To me, all the value of a data class comes from its destructability
    g
    • 2
    • 3
  • m

    mg6maciej

    04/01/2017, 8:40 PM
    Also
    !in
    ->
    is not in
    .
    ➕ 5
    g
    b
    +2
    • 5
    • 13
  • m

    mbstavola

    04/05/2017, 5:08 PM
    Not really a formal proposal or anything, but I feel like it'd be really powerful if we could have something like Rust's move semantics-- change the scope in which a reference is valid. I think it could be useful for APIs that consume values, preventing people from reusing stuff after it's passed in.
    ➕ 1
    r
    c
    +3
    • 6
    • 14
  • d

    dean

    04/11/2017, 4:24 AM
    A Multi-dimensional array implementation would be cool, similar to the one in C#, rather than using Java's jagged arrays. So you could make a 2x4 array
    arr
    , and because we know the width and height are fixed to 2 and 4, we can make it a 1D array of length 8.
    m
    • 2
    • 4
  • d

    dmitry.petrov

    04/12/2017, 8:15 AM
    https://youtrack.jetbrains.com/issue/KT-83
    c
    • 2
    • 2
  • c

    cbruegg

    04/12/2017, 11:26 AM
    Interesting workaround..
    b
    • 2
    • 1
  • b

    benleggiero

    04/17/2017, 11:45 PM
    Sounds like #stdlib
    d
    • 2
    • 2
  • n

    nimtiazm

    04/19/2017, 2:33 PM
    Ok i’ve created one. https://github.com/Kotlin/KEEP/issues/69
    b
    • 2
    • 4
  • n

    nimtiazm

    04/19/2017, 2:58 PM
    one question i’m honestly still thinking on is if there’s any possibility an object could be made immutable just by expressing it like
    const val list = ArrayList<..>()
    and list.add(..) shouldn’t be possible
    m
    k
    • 3
    • 16
Powered by Linen
Title
n

nimtiazm

04/19/2017, 2:58 PM
one question i’m honestly still thinking on is if there’s any possibility an object could be made immutable just by expressing it like
const val list = ArrayList<..>()
and list.add(..) shouldn’t be possible
m

mg6maciej

04/19/2017, 3:06 PM
With
val list: List<...> = ArrayList<..>()
list.add(..)
is not possible.
(from Kotlin code)
n

nimtiazm

04/19/2017, 3:09 PM
val list = ArrayList<Int>()
	println(list.count())
	list.add(1)
	println(list.count())
is it a WAT! ?
m

mg6maciej

04/19/2017, 3:11 PM
Change your first line to
val list: List<Int> = ArrayList<Int>()
n

nimtiazm

04/19/2017, 3:11 PM
yeah but i use type-inference wherever I can
you see my point? from my perspective it’s broken
m

mg6maciej

04/19/2017, 3:14 PM
If you are using
ArrayList
, then you clearly want to mutate it. If you want a list that does not allow mutation, use a
List
interface there. You specifically mentioned function arguments in your original proposal. Use
List<Int>
as function argument type and you may pass
ArrayList<Int>
there. You will not be allowed (unless you cast) to call
add
in that function.
n

nimtiazm

04/19/2017, 3:15 PM
yes you have to specify an immutable interface there. what i’m investigating is if there’s any way this could be unified with type-system so somehow you give a hint to compiler about your mutators and compiler could help you wtih that
a straight forward way would be to introduce a language-level @annotation to mark mutating methods and then if you call any of these after specifying
val
ref, compiler would be able to stop you
m

mg6maciej

04/19/2017, 3:17 PM
If you are looking for type system that does not allow mutations by default, try Haskell (or eta-lang.org for JVM equivalent).
n

nimtiazm

04/19/2017, 3:18 PM
why not if kotlin could have it. if it makes sense to teh community
because i use and love kotlin 🙂 like a lot of others
m

mg6maciej

04/19/2017, 3:24 PM
I do use Kotlin extensively too. I'm generally happy with what is it now and apart from few minor things I don't feel it needs to get more complicated. In my eyes you failed to provide explanation to what you exactly want changed and why you want it like that. Adding
const
to arguments have no meaning. Arguments cannot be reassigned and
const
has different meaning in language.
const val myConst = 5
will be inlined across the bytecode. That's the meaning of
const
.
n

nimtiazm

04/19/2017, 3:28 PM
at strawman level you never decide if it’s gonna be a new keyword or reusing existing keyword might work it out. you try to keep it minimum so the intent is delivered. I’m not sure if you still understand that i’m talking about two problems and how they are connected.
k

kingsley

04/20/2017, 6:47 AM
@nimtiazm why not just do
val list = listOf<Int>()
which solves your problem with type inference and mutability
View count: 1