<Perelandric>
Does it actually *require* traits or interfaces to be able to call methods?
<SeanTAllen>
you have to constrain T to be of a type that conforms to the interface you need, which means you need to name the interface and constrain T to that
<SeanTAllen>
see the gist Perelandric, i put what you need in the comments
gsteed has joined #ponylang
<Perelandric>
SeanTAllen: Thanks. I understand that it can be done with constraints. I guess I just thought that it could be done without...
<Perelandric>
...and that the compiler when generating the specific code would catch stuff that wouldn't match the type.
<Perelandric>
But that answers my question.
<SeanTAllen>
It needs to be able to work for any T
<SeanTAllen>
Any T that you define as being valid
<Perelandric>
So the generic types are fully analysed before they're ever expanded...
<Perelandric>
... instead being analysed after the expansion in the case of unconstrained types.
<SeanTAllen>
I've read that a few times and i'm having a hard time parsing it
<SeanTAllen>
I'm not sure what "expanded" means but I think you are thinking of generics like type checked macros, which they aren't.
<SeanTAllen>
what you say when you have class Foo[T] is that T is of type Any
<SeanTAllen>
which means that you can only use like you would an Any
<SeanTAllen>
the Any is implicit in that definition you wrote, any type can work here
<Perelandric>
SeanTAllen: Thank you. That greatly sheds light on the flaw in my understanding.
<mcguire>
Perelandric, AIUI, A C++ template would do what you expect: you plug a type Bar into foo(t:T), the compiler expands the template like a macro, and *then* the compiler typechecks the resulting code.
<mcguire>
Pony, Java, Rust, etc., do it the opposite way: they typecheck the generic class or whatever, then separately check the uses of the class. To get the class to compile, you have to specify the requirements on T: the trait (or whatever) needed to supply the test() method.
<Perelandric>
mcguire: Thank you, that does explain my flawed mental model very well.
<Perelandric>
I'm ultimately trying to figure out why I can't get a specific generic implementation to work.
<Perelandric>
It is boiling down to the definition of rcaps in a specific spot...
<Perelandric>
and so I'm starting over and making sure I'm understanding things from the ground up.
<Perelandric>
Sean's and your comments are very helpful to that end.
jemc has joined #ponylang
amclain has joined #ponylang
SilverKey has joined #ponylang
Praetonus has quit [Quit: Leaving]
montanonic has joined #ponylang
gsteed has quit [Ping timeout: 260 seconds]
amclain_ has joined #ponylang
amclain has quit [Ping timeout: 244 seconds]
amclain_ has quit [Client Quit]
amclain has joined #ponylang
aturley has quit [Ping timeout: 252 seconds]
gsteed has joined #ponylang
Praetonus has joined #ponylang
Matthias247 has joined #ponylang
_andre has quit [Quit: leaving]
mcguire1 has joined #ponylang
michael_campbell has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
gsteed has quit [Quit: Leaving]
Matthias247 has quit [Read error: Connection reset by peer]