jemc changed the topic of #ponylang to: Welcome! Please check out our Code of Conduct => https://github.com/ponylang/ponyc/blob/master/CODE_OF_CONDUCT.md | Public IRC logs are available => http://irclog.whitequark.org/ponylang
jemc has quit [Ping timeout: 258 seconds]
FunkyBob has joined #ponylang
<FunkyBob> morning, all
<FunkyBob> just verifying as I get started with pony.... I'd use a primitive for declaring consts, yes?
<doublec> FunkyBob: yep
<doublec> FunkyBob: primitives can't have fields so you'd use functions returning the value
<doublec> FunkyBob: see regex/regex.pony for an example
<FunkyBob> thanks
<FunkyBob> and all methods anf fields on an instance are implicitly in its scope?
<FunkyBob> there's no self or this?
<doublec> FunkyBob: On a primitive?
<FunkyBob> hmm.. point
<doublec> FunkyBob: there's a 'this' in classes and actors
<FunkyBob> it's a form of singleton, yes?
<FunkyBob> ok
<doublec> FunkyBob: primitives have one too but there singleton like you say
<doublec> s/there/they're/
<FunkyBob> just getting buried in the amount of boilerplate I'm queueing up to generate :)
<doublec> heh, are you wrapping a C library?
<FunkyBob> no
<FunkyBob> friend of mine wrote a Python VM in JS... so I'm retorting by writing one in Pony :P
<doublec> nice
* FunkyBob is sitting at the sprints at PyConAU
<FunkyBob> ah... just saw in docs:
<FunkyBob> primitive Red fun apply(): U32 => 0xFF0000FF
<FunkyBob> sad I can't just do primitive Thing => value
<FunkyBob> can I do apply() => U8: 'a' ?
<doublec> FunkyBob: yes, but it's: apply(): U8 => 'a'
<FunkyBob> oops, thanks :)
<FunkyBob> so, I have a type that is a | of 29 primitives... yay...
<doublec> Sounds like a lexer or ast of some sort :)
montanonic has quit [Ping timeout: 276 seconds]
<FunkyBob> indeed
<FunkyBob> this is for the de-marshal code to read the bycode
<FunkyBob> ~ is bitwise inversion?
c355e3b has quit [Quit: Connection closed for inactivity]
<doublec> I don't know sorry
<FunkyBob> in a match block... want two cases to work the same... can I do "| (A | B) =>" ?
<doublec> FunkyBob: yes
Dyserna_ has joined #ponylang
Dyserna__ has quit [Ping timeout: 265 seconds]
Perelandric has quit [Ping timeout: 264 seconds]
montanonic has joined #ponylang
jemc has joined #ponylang
mcguire2 has quit [Ping timeout: 244 seconds]
mcguire has joined #ponylang
srenatus[m] has quit [Read error: Connection reset by peer]
M-hrjet has quit [Remote host closed the connection]
srenatus[m] has joined #ponylang
M-hrjet has joined #ponylang
Matthias247 has joined #ponylang
jemc has quit [Ping timeout: 258 seconds]
amclain has quit [Quit: Leaving]
Matthias247 has quit [Read error: Connection reset by peer]
montanonic has quit [Ping timeout: 276 seconds]
c355e3b has joined #ponylang
_andre has joined #ponylang
Praetonus has joined #ponylang
Perelandric has joined #ponylang
<Perelandric> Very basic generics question. My understanding is if you have `class Foo[T]`, and make `Foo[Bar]`, then `T` becomes `Bar`.
<Perelandric> So if my generic class has `fun foo(t: T) => t.test()`, and `Bar` has a `.test()` method, why doesn't it compile?
<Perelandric> My basic understanding must be flawed.
<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]
Praetonus has quit [Quit: Leaving]
SilverKey has quit [Ping timeout: 252 seconds]