ursus
01/14/2019, 10:24 PMstephan_marshay
01/14/2019, 10:25 PMJava
emoji...ursus
01/14/2019, 10:32 PMursus
01/14/2019, 10:35 PMxenoterracide
01/14/2019, 11:22 PMoverride fun isTo1Hz(from: InputStream, cb: Consumer<Int> = {} ): List<List<EngDataStructure>> {
how do I do what I mean, an optional callback? also will Int be resolved as Integer for java consumers?jw
01/14/2019, 11:22 PM(Int) -> Unit = {}
jw
01/14/2019, 11:23 PMConsumer
to avoid return Unit.INSTANCE
nonsensexenoterracide
01/14/2019, 11:24 PMuser
08/14/2020, 3:07 PMJoel Pedraza
08/14/2020, 6:04 PMunsafe
blocks. Curious if there would be a way with lint in UAST to error if any property or method with some annotation is called outside of some block like
data class Foo(@Secret val password: String)
foo.someSecret
would error but the following is ok
omgAuditThisPls {
foo.someSecret
}
This is a contrived example, because foo.toString() could leak secrets but that can be handled by another abstractionBig Chungus
08/16/2020, 9:21 PMursus
08/17/2020, 3:38 AMprotected fun setState(reducer: S.() -> S) {
val oldState = stateRelay.value!!
stateRelay.accept(oldState.reducer())
}
callsite:
setState {
copy(foo = "bar")
}
ursus
08/17/2020, 3:39 AMcopy
away, and have its parameters on the reducer?. i.e.
setState {
foo = "bar"
}
Luis Daivid
08/17/2020, 9:44 AMLuis Daivid
08/17/2020, 9:46 AMBob Glamm
08/17/2020, 1:25 PMlaith
08/17/2020, 5:21 PMuser
08/17/2020, 6:09 PMigor.wojda
08/17/2020, 11:03 PMVinod Rai
08/18/2020, 4:59 PMLeoColman
08/18/2020, 11:31 PMuser
08/19/2020, 11:18 AMuser
08/19/2020, 4:28 PMluke
08/19/2020, 5:13 PMalwyn
08/20/2020, 3:45 PMTijmen van der Kemp
08/20/2020, 8:22 PMA {
value1
value2
B {
value3
...
}
}
etc, done a million times before.
My task is to create the following: an external party comes in with an XML definition of which entities/values they want to receive, a la GraphQL / ProtoBuf. In addition to this, we need to create "standard" messages with predefined schemas, so not only do the external party give XML, our programmers also need to define some of those messages.
I want to do this last part type safe, so my first thought was a Kotlin DSL. I've got most of it working, it's kind of looking like this:
aScope = scope(AModel) {
addField(AModel.value1)
addEntity(BModel) {
addField(BModel.value3)
}
}
object AModel {
val value1 = field<String>()
val value2 = field<Int>()
}
This all works fine already, but I want it to be type-safe. For example, right now this is legal:
aScope = scope(AModel) {
addField(BModel.value3)
}
To add to the complexity, some entities have common fields, so like a good OO monkey I gave the Model objects abstract superclasses with more fields in them, which is nice, because you can do AModel.commonField and BModel.commonField and they're different unique fields :D
I think to accomplish this, I have to encode the enclosing Model class on a field somehow. Then I could do something like
fun Scope<ModelClass>.addField(field: Field<ModelClass>) { ... }
but I can't figure out how to do this without being extremely verbose like
object AModel {
val value1 = field<AModel, String>()
}
and even then I can't get the common fields to work, because I can't seem to pass the actual Model class upwards to the abstract superclass.
Any advice is welcome, and sorry for the book! Your help is much appreciated!
Kind regards, TijmenNir
08/21/2020, 10:35 PM//Object a matcher object from the supplied Glob pattern
val matcher = FileSystems.getDefault().getPathMatcher(glob)
val path = Paths.get(start)
//Walk the file system
Files.walk(path)
//Filter out anything that doesn't match the glob
.filter { it : Path? -> it?.let { matcher.matches(it.fileName) } ?: false }
//Collect to a list
.collect(toList())
Not only is this code ugly, but it also seems incredibly inefficient to walk every file and filter, compared to how globs can actually be done. I don't have much faith in this snippet anyhow because there's some oddities but it's the best I'd found.Mehdi Haghgoo
08/22/2020, 7:52 AM