« first day (4421 days earlier)      last day (720 days later) » 

20:00
I have a class that looks like abstract class NodeVisitor<N: Node<N>, R> and has lots of functions that take N and return R
why is N recursive
I want each function to be able to return a different subclass of N, but currently they can all only return N itself
@Seggan because it made the errors go away :p
/srs that's the type of the child
a Node<N> can only have children of type N, and I want it to only have its own type as its children
I've made a type that's its own parent and child :b
it's like Time Travel 101 all over again
2
why not just N : Node<*>
20:03
lemme try it
because that causes errors
how
what errors
protected fun visit(node: N): R {
    return node.accept(this)
}
that errors with Type mismatch: inferred type is NodeVisitor<N, R> but Nothing was expected
regardless, that's not the problem I want solved
@Ginger ah yes because the compiler doesnt know the type it wants accepted
your only solution is to break the recursion i think
Nothing was expected
sounds like kotlin needs to get some higher standards :P
the recursion is a. intentional and b. not the issue I want solved
20:08
@Ginger Ooh a protected fun visit! Like a field trip!
Time Travel 101 has field trips?
:D
@Seggan yeah, at the end of every year we go back to the start of class so we can laugh at how stupid our past selves were
it's great
@Ginger hrm but according to oop you should be able to return a subclass for a superclass, no?
@Seggan yes
but if I hover over the declaration it says that N is being replaced with UntypedNode at compile-time
I want it to be left generic
presumably what you're really looking for is specializing the generic multiple different ways?
20:12
yes, probably
@Ginger yes, because type erasure
can I keep it from being erased?
the jvm does not keep generic type information
@Ginger only by using inline classes
but those are quite limited
or do something to signify that the return type can be any subclass of N?
@Seggan tell me more...
@Ginger the return type is N, which by oop can also be any subclass
20:15
oh yikes you weren't kidding about them being limited
actually reified generics dont even work with inline classes
only inline functions
is there any way to make this work???
because I will be much sad if I have to put casts everywhere
2 mins ago, by Seggan
@Ginger the return type is N, which by oop can also be any subclass
but it no worky
well, ig its a good thing Time Travel 101 warns you about the fact that the universe hates time travel
(did it? mine did)
20:19
it did
20:39
@Seggan Indeed
@Seggan wdym
We time travel all the time
Can't control where you travel but you travel ;P
20:53
@user i meant to the past

Time Travel 101

51 mins ago, 51 minutes total – 51 messages, 6 users, 1 star

Bookmarked 5 secs ago by Seggan

A message a minute, nice
im still in pre-time travel
we do simulations in cardboard boxes
For some reason I found myself attempting to implement the fixed-point combinator using C++ templates. Knowing how C++ templates are abused, that probably already exists...
6
Q: Fixed point combinator in C++1x

Earth EngineThis has been tested and compiled under Visual Studio 2010. Are there any serious problems with this implementation? PS. This implementation is fully lambda expression based. If I can make fixpoint::fix a real member function it will be simpler than this. //As decltype(variable)::member_name is...

21:08
No, that uses operator(), I meant something like
template<class T>
struct y {
   using type = T<y<T>::type>;
};
But I imagine that's not legal as written
ಠ_ಠ
The motivation I had for this isn't even a good one
template<class T>
class foo : public T {};

foo<foo> // Wait, you can't do that...

template<class T>
struct y {
   using type = T<y<T>::type>;
};

y<foo>::type // infinite recursion much?
To be clear, that first class declaration is legal C++
21:51
okay, in theory Rabbit should be functional now
in theory
oh wait nvm I forgot a bit
Woot, I fixed my memory leak and now have a scrolling bitmap!
C really will just let you footgun yourself on every turn, huh?
Why does my binary size change by ~500 bytes when I reorder some enum cases
Compilers are magic
well
I did it
let's see if it runs
Like, if it made a little difference because it figured out some bitwise magic, I would understand that. But 500B is more than I expected
22:05
me when build failed
nice, we got a successful compile
time for run
history is about to made
Oh! I figured it out! When I reordered my cases, it reduced one function from a long switch statement to arg ^ 1 and another to arg & 2 ? arg : arg ^ 4.
you'll never guess what happened
it crashed
oh, I named my main function main (a keyword) :/
crashed again because I tried to cast an UntypedFunctionDeclaration to an UntypedStatements somehow
I forgot to remove a test cast :|
> Exception in thread "main" java.lang.IllegalStateException: ?!
thanks past Ginger, very cool
I told you, it's TRUE, not true.
@ATaco C is glorified assembly language
Haha no overhead go BRRRRRRR
22:20
@ATaco Sometimes you really need to get your shoe off and a gun is the only tool you have
If you aim very carefully, you won't hurt yourself :P
(This sounds like a scene from a cheesy action movie, TBH--one of the kind where someone loses a limb and attaches a gun as a prosthesis)
Guns Akimbo, staring Daniel Radcliff
He gets kidnapped and guns affixed to his hands.
@ATaco thats why c++ is bad. it tries to add GP stuff to glorified assembly language
and it fails at that mixture horribly
@ATaco That, or I think the Quentin Tarantino movie Grindhouse has a woman with an automatic rifle for a leg. (Not that I've watched either movie.)
I do not like C++, too many librarys :(
@Seggan how do I check if a Kotlin object is a subclass of a type? is doesn't seem to work
22:26
@Seggan That's... a really succinct and coherent argument, actually. I'll have to remember that one.
GP as in general purpose
@Ginger a is WhateverClass?
i dont see why it wouldnt work
oh wait nvm lol
I am square brain
AAAAGH it almost worked!
@DLosc i wonder how rust managed to do it though
i think its bc they started with simple GP features and added the low level stuff, rather than the other way around
@Seggan how do I get a HashMap to return the same value for two different instances of an inline class?
(their values are the same ofc)
2 messages moved from Vyxal
(for context, I approved the above)
22:38
cool
@Ginger why are you using inline classes?
because it is what it is
@Ginger Make two copy or box it
don't ask questions just provide answers
m[k1] = v; m[k2] = v
Exactly the same as you would do in other languages
22:40
also i think you can just override equals if i understand ur q
@Seggan yeah probably, how do I do that?
@Ginger those are for extraordinary use cases
@Ginger ...
I'm an extraordinary kinda person
im quite sure you know how to override a method
ohhh right lol
was confused
@Seggan doesn't work
@Seggan I think I can fix it by overriding hashCode(), but the problem is that that also differs between strings (I think)
okay what in the frick
it doesn't, so why isn't this working?!
22:48
@Ginger no it doesnt
and yes you have to override hashcode too
wait, I have to do both???
yes
hashmaps search by hashcodes first
still doesn't work
code?
my logs indicate that equals isn't called either
class Identifier(val name: String) {
    override fun toString(): String {
        return name
    }
    override operator fun equals(other: Any?): Boolean {
        return name.equals(other)
    }
    override fun hashCode(): Int {
        return name.hashCode()
    }
}
@Seggan ^
22:52
first, thats not an inline class
second, equals is not implemented improperly
think about it
@Seggan I know, Kotlin doesn't let inline classes override hashCode or equals
mhm
@Seggan I may be stupid
*not
what does identA == identB eventually turn into?
wait, if I add a println to equals it doesn't get called
22:54
identA.equals(identB) -> identA.name.equals(identB) see the error?
ohhhhhhhhhhhhhhhhhhh
regardless, equals isn't called at any point
thats abnormal
can i see the map code?
could you be more specific? I've got lots of map code :p
as in the code you need help with
fun get(key: Identifier): RabbitObject {
    return this.variables.getOrDefault(key, this.parent?.get(key) ?: error("No such key $key"))
}
22:57
@Ginger I feel like this live debugging chat is getting to be a bit too much. Would you mind creating a Kotlin room and moving it there?
@DLosc I would, because it's very much on-topic here
it's "general discussion", so I think programming talk counts as on-topic discussion
also, nobody's discussing anything else
regardless: @Seggan that's the code causing the error
@DLosc be glad you weren't around for the two hours of explaining linear interpolation yesterday then :p
@Ginger have you checked the contents of the maps?
use a debugger, for codes sake
@Seggan my debugger is crap and doesn't work properly
but I know for a fact that the map (at the point where it errors) contains an Identifier containing the string print
I also know for a fact that that's what's being passed to the get function
uh, I just checked and the hash codes are exactly the same
something else must be going on
@lyxal I wouldn't have minded that because it's a topic I find interesting, but if someone had suggested moving it to a different room I would 100% have agreed
23:15
@Ginger try manually invoking equals
@Ginger print them
@Seggan {print=community.rto.ginger.rabbit.interpreter.WrappedFunctionDeclaration@52f759d7}
@Seggan it says they're equal
@lyxal I'm reading the transcript now and it's a wild ride X^D
@DLosc as I said, be glad :p
@Ginger i found whats wrong
oh boy
23:22
getOrDefault has to evaluate both args before getting
you follow?
I KNEW IT
I was sure it was an issue with that
i think kotlin has one with a lambda that is evaluated only on null
ig you can turn it back into an inline class now :P
or you can use elvis
I am using elvis
this.variables[key] ?: (this.parent?.get(key) ?: error("No such key $key"))
ohhhhhhhhh
23:31
works?
having tech issues

« first day (4421 days earlier)      last day (720 days later) »