https://kotlinlang.org logo
Title
n

nfrankel

10/29/2018, 6:52 PM
i expect line 35 to fail at compile time but it doesn’t... 😞
h

hho

10/29/2018, 6:53 PM
You mean line 33?
35 is the last }
n

nfrankel

10/29/2018, 6:54 PM
i mean line 35 because the
company
lambda shouldn’t be called twice
k

karelpeeters

10/29/2018, 6:54 PM
Ah no, the compiler doesn't do any verification like that.
There's a line in the KEEP about that, let me go hunt it down.
n

nfrankel

10/29/2018, 6:55 PM
oh, did i misunderstand that?
d

dsavvinov

10/29/2018, 6:56 PM
Sorry, I'm not sure I'm following your example. Why exactly line 35 should fail at compile time?
h

hho

10/29/2018, 6:56 PM
I think it works the other way around: You assure the compiler that you will only call it once. The compiler then accepts it e.g. when setting a val.
☝️ 2
n

nfrankel

10/29/2018, 6:58 PM
@karelpeeters @hho thanks for the clarification i totally misunderstood then
z

zsmb

10/29/2018, 6:59 PM
It will supposedly be checked and enforced at some point in the future, but for now, it's our responsibility to keep our word about contracts
k

karelpeeters

10/29/2018, 7:00 PM
I doubt the "enforced" part, there's this halting problem...
z

zsmb

10/29/2018, 7:01 PM
Well, yes, for obvious cases at least 🙂
d

dsavvinov

10/29/2018, 7:01 PM
Well, it depends on what you're trying to enforce... 🙂
n

nfrankel

10/29/2018, 7:01 PM
in my case, i’d like to prevent calling the
company
twice
d

dsavvinov

10/29/2018, 7:03 PM
Yeah, I got your example @nfrankel -- missed the
AT_MOST_ONCE
part. While it is true that it works the other way currently, we're considering use cases like that and actually they have quite high priority on the list of possible contracts use cases. So, stay tuned, maybe we will have something for you in the future 😉
👍 2
k

karelpeeters

10/29/2018, 7:03 PM
You can take a
Company
as a constructor parameter to encourage that, I don't think there's a way to enforce it for now 😉
n

nfrankel

10/29/2018, 7:04 PM
@dsavvinov that would be great
@karelpeeters that wouldn’t work with a real-world example i’d like to have a full-fledged model in the dsl