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 | Please consider participating in our mailing lists => https://pony.groups.io/g/pony
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
acarrico has quit [Ping timeout: 255 seconds]
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Quit: khan]
SenasOzys has quit [Ping timeout: 260 seconds]
khan has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
SenasOzys has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
jemc has joined #ponylang
SenasOzys has quit [Ping timeout: 260 seconds]
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
jemc has quit [Ping timeout: 268 seconds]
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Quit: khan]
SenasOzys has joined #ponylang
khan has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan_ has joined #ponylang
khan has quit [Ping timeout: 265 seconds]
khan_ is now known as khan
khan_ has joined #ponylang
khan has quit [Ping timeout: 256 seconds]
khan_ is now known as khan
khan has quit [Quit: khan]
gokr has quit [Ping timeout: 248 seconds]
SenasOzys has quit [Ping timeout: 240 seconds]
acarrico has joined #ponylang
SenasOzys has joined #ponylang
acarrico has quit [Ping timeout: 264 seconds]
droman has joined #ponylang
<jtfmumm> vaninwagen: One way is to use a trait like this: https://playground.ponylang.org/?gist=ccb381a7787d5200aaab6db774698f55
<jtfmumm> This gets your code in Main to compile.
<jtfmumm> I'm not sure exactly what use case you're interested in, but here you could add a method to the trait and implement that method on both Parameterized and DontCareAboutGenerics (i.e. you could have them both implement the trait). That might look like: https://playground.ponylang.org/?gist=a7cbb41d318f2a72791c7c4073272ef9
<jtfmumm> and here's a version that uses two distinct parameterized types: https://playground.ponylang.org/?gist=4563a58f2cc05b6f81646bc5689351f4
khan has joined #ponylang
SenasOzys has quit [Ping timeout: 240 seconds]
khan has quit [Quit: khan]
khan has joined #ponylang
brainpro1 has quit [Ping timeout: 240 seconds]
khan has quit [Quit: khan]
khan has joined #ponylang
SenasOzys has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
brainpro1 has joined #ponylang
brainpro1 has quit [Ping timeout: 240 seconds]
<SeanTAllen> if you have time jftmumm, that would make a great pony pattern
brainpro1 has joined #ponylang
<strmpnk> Simulating generic type erasure. I still need to get a better handle on where traits vs interfaces work best. The differences feel too subtle to drive me to one over the other when I am writing the types which implement the concept.
droman_ has joined #ponylang
droman has quit [Ping timeout: 276 seconds]
vaninwagen has joined #ponylang
<vaninwagen> The moment you've all been waiting for:
<vaninwagen> ...
<vaninwagen> ...
<vaninwagen> ...
<vaninwagen> ᕕ( ᐛ )ᕗ
<SeanTAllen> ᕕ( ᐛ )ᕗ
alexashka has joined #ponylang
<alexashka> good day, forgive my beginner question - I can do let someString: String iso = recover String end. How do I go about doing that for a boolean?
<vaninwagen> alexashka: hi! :) a Boolean is basically always val
<alexashka> vaninwagen: because it is a primitive? and primitives are val by default?
<vaninwagen> yes, Bool and floats and all integers are a little special as they are represented as machine words
<vaninwagen> whereas a String is an actual class with a size and some byte array underneath - so it can be mutable, while this is not possible for some, say Bool
<alexashka> are classes val by default too?
<alexashka> perhaps a better question - how do I print out the type of an object in pony ;0
<vaninwagen> no, if you don't specify anything they are ref
<alexashka> ok, so then why does var a: String ref = "hello" fail to compile?
<vaninwagen> alexashka: printing a type, that is something that is not possible yet, as there is no reflection at all yet
<vaninwagen> alexashka: yeah, let me get you the picture of class refcaps in some messages:
<vaninwagen> you can do `class val MyImmutableClass` - this means that every variable that you declare as `MyImmutableClass` (without refcaps) will actually be `MyImmutableClass val`
<vaninwagen> this is the default refcap
<alexashka> ah, String is declared as class val String...
<vaninwagen> then there is the refcap that constructors return, a constructor for `MyImmutableClass` written as: `new val create() => ...` will return you a `MyImmutableClass val`
<vaninwagen> regardless of what the default refcap is
<vaninwagen> so there is two places to look for
<vaninwagen> and the constructor `String.create` returns you a `String ref` while the default refcap of String is `val`
<vaninwagen> for most classes these are the same, but in case of String we have some special case
<vaninwagen> usually you have String literals, that are `val` (immutable), but if you create an empty `String` via constructor, you usually want a mutable on (to append some bytes), thus it returns a `ref`
* vaninwagen drinks a glass of water after all this talking ;)
<alexashka> ok, so how does a beginner navigate this? I'm hoping there's a better way than looking at the implementation of every object to find out what it's refcaps will be
<vaninwagen> i am consulting https://stdlib.ponylang.org/builtin-String on a regular basis
<vaninwagen> the stdlib docs will have a full source code listing with the next release, so you can navigate all you need to know with some clicks
gokr has joined #ponylang
<SeanTAllen> i generally dont use the online docs, i refer to the source on my machine.
<alexashka> would this be the source file for string? https://github.com/ponylang/ponyc/blob/master/packages/builtin/string.pony - it doesn't seem to have new create ref mentioned in the docs
<vaninwagen> the constructor `create` is `ref` by default, if no other cap is provided
<alexashka> right. so I'm still a little lost - coming from other languages - there's a default initializer. When I go var a = String, what is being called behind the scenes here?
<vaninwagen> if you just use the typename like in your example above, this expands to `String.create()`
<alexashka> right, so then when would class val String, when would the val part become significant? If there's an alternate initializer that doesn't specify a refcap, it defaults to val?
<vaninwagen> the default capability is also just sugar, os you can say `let x: String` instead of doing `let x: String val` all the time. this has nothing to do with the constructor stuff
<alexashka> ah this is maddening, let me try another way - when I go let str = "hello", what does "hello" desugar to?
<vaninwagen> a string literal is always a String val
<vaninwagen> sorry for being not as helpful here, i guess i lost myself in explaining
<alexashka> hehe I appreciate us communicating ;0
<alexashka> I just wish the "duh" moments would be provided upfront - for instance, I have a class with a name field, I'd like to instantiate the class by passing a String to the constructor. But I want the name to be a ref. The string I'm passing in is a val, so how do I convert it to a ref?
<vaninwagen> you know the playground? https://playground.ponylang.org/ increadibly useful for toying around and checking some questions with a quick sample
<alexashka> ah great point, let me try that
<SeanTAllen> you can't convert a val to a ref. that would be unsafe.
<SeanTAllen> you can clone the val and the clone can be a ref.
<vaninwagen> for your case above - this is actually unsafe, unless you clone the String
<vaninwagen> yeah, hehe
<alexashka> SeanTAllen: right that's what I'm thinking, so what's the usual pattern here? To simply clone?
<SeanTAllen> i cant answer that as i dont really understand your case.
<vaninwagen> SeanTAllen is actually my side kick, kicking when a default timeout hits
<SeanTAllen> why are you passing a val instead of a ref to your constructor?
<SeanTAllen> if you want a ref, require a ref. that would be my advice.
<SeanTAllen> There's a lot going on there and its a toy example, so its hard to tell you what to do.
<alexashka> well I'd like to get it to compile for one :)
<alexashka> if this were any other language - this would not be a lot going on - I'm instantiating a class and passing a string into the constructor
<alexashka> this is objects 101 as far as I can tell
<vaninwagen> i feel ya. here is a working example: https://playground.ponylang.org/?gist=54e653e72782c66d7f84ed61c5676e36 following SeanTAllens advice
<alexashka> ah, you snuck in the .> operator. What i was bangign my head against the wall with was creating a String ref as a oneliner with a value
<SeanTAllen> ah yeah... let someName = String.>append("Bobby") would be better for that part
<alexashka> SeanTAllen: right, surely you'd agree creating a mutable strign should not be voodoo requiring the understanding of 5 concepts at once :)
<SeanTAllen> ¯\_(ツ)_/¯
<alexashka> SeanTAllen: which's what your example perfectly illustrates
<SeanTAllen> what would your suggestion be? String literals to me mutable?
<alexashka> SeanTAllen: no no, I'd suggest having examples like the one you posted, included in the tutorial
<alexashka> SeanTAllen: becaues currently, it's very theory heavy, very beginner hostile
<SeanTAllen> we are open to suggestions and PR
<SeanTAllen> saying "examples like the one I posted" doesnt help me improve the tutorial much.
<SeanTAllen> where would that go?
<SeanTAllen> when?
<SeanTAllen> why?
<SeanTAllen> if you could give more details that would be helpful
<SeanTAllen> we have not written the tutorial to be hostile
<SeanTAllen> i'm sorry you are struggling.
<vaninwagen> alexashka the whole refcap type-system is very deep and needs to be to ensure safety, and this affects even the smallest part of your program. this is the steep learning curve all the veterans talk about.
<alexashka> SeanTAllen: absolutely. I am a fan of 'explain like I'm 5' - I'd have 'here's how you do the same thing you do in Java in Pony'
<SeanTAllen> where would you put that in the tutorial?
<alexashka> and here's why it's different, and a little more complex, BUT you get benefit XYZ
<SeanTAllen> its not really appropriate at the start, what if the user doesn't know java?
<vaninwagen> I somehow got used to keeping this additional dimension in mind all the time, but it is quite a task to get into it.
<alexashka> SeanTAllen: I think it'd be good to write one tutorial for java, and then port it to another 2-3 very popular languages
<alexashka> to have side by side examples of here's how the very very basics are done
<vaninwagen> But once you are able to "go with the flow", this is where the fun starts
<SeanTAllen> we asked for folks to write "Pony for X" intros. So far no one has stepped forward.
<SeanTAllen> its a volunteer project.
<SeanTAllen> we all have jobs etc. so we do what we can.
<alexashka> SeanTAllen: ya, I'd be happy to give it a try
<SeanTAllen> i guess once folks learn it, they dont have much interest in writing a Pony for X.
<alexashka> SeanTAllen: once I can get mutable string instantiation going :D haha
<SeanTAllen> alexashka: if you want to tackle it, that would be great
<alexashka> SeanTAllen: ya, I think it's a programming-wide problem, of documentation
<alexashka> SeanTAllen: the more ppowerful the language, the worse the docs it seems, Haskell being a prime example :)
<SeanTAllen> we have put a good amount of time into documentation. im sorry you find it lacking.
<SeanTAllen> as someone who has spent a lot of time on documentation, it stings a little that you basically said the docs aren't good (or pony isnt very powerful).
<alexashka> SeanTAllen: ya, I think very smart people have trouble documenting for mere mortals, it's almost incompatible
<vaninwagen> a usual saying of haskell guys: "just follow the types" - should we put this down as "just follow the refcaps"?
<alexashka> SeanTAllen: I think pony's very interesting - I didn't mean to hurt feelings re the documentation
<alexashka> SeanTAllen: I think it's fair to say if you take someone who's only done OO, and isn't interested in programming language theory, they'd be utterly lost with Pony
<SeanTAllen> alexashka: plenty of folks find the docs good and compliment them, plenty of folks have a hard time.
<SeanTAllen> its a matter of background.
<SeanTAllen> alexashka: plenty such folks have picked up Pony with the existing documentation.
<SeanTAllen> people learn differently, i'm sorry you are having difficulty.
<alexashka> ya, I hear you. I'm sorry too, I didn't mean to offend you
<SeanTAllen> i'm not offended. writing documentation when the backgrounds of the potential audience are vast is very difficult.
<SeanTAllen> its why 2-3 years ago i tried to get folks to write Pony for X intros but no one followed through, because of time constraints or whatever else.
<alexashka> SeanTAllen: you're right. I'll bother the people in here with very beginner questions for a while and if I get someplace decent, I'll try a write-up that's amenable to people with my IQ :)
<alexashka> SeanTAllen: ya, people like to write code, not documentation it seems. Very unfortunate
<SeanTAllen> plenty of folks start work on code and end up not finishing that as well
<SeanTAllen> i dont think your struggles are in any way reflective of IQ. learning new ideas is hard. the level of difficulty depends on what you are already familiar with. that has nothing to do with IQ.
<SeanTAllen> if you wanted to write a Pony for Java Programmers, that would be great.
<SeanTAllen> There's a bit of Java content already in the Pony for X repo: https://github.com/ponylang/pony-for-x
vaninwagen has quit [Quit: WeeChat 2.1]
<SeanTAllen> but im pretty sure that code would need to be updated as there have been many breaking changes since then.
<SeanTAllen> if you wanted to bring that up to date/add more content, that would be awesome
<SeanTAllen> there's a mailing list for such content, its been dormant for 2 years: https://pony.groups.io/g/book/topics
<alexashka> SeanTAllen: ya, I'm all for it. I'm assuming this is the best place to show folks a draft or two to get some feedback?
<SeanTAllen> that and PRs, yes.
<alexashka> I can see that the idea of pony for x has been around for a while - I'm glad. So it's just a matter of doing it
<SeanTAllen> anyway, got to run. ill check back later to see if there are other questions i can help with.
<alexashka> great, thanks for the chat
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
acarrico has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
gokr has quit [Ping timeout: 240 seconds]
gokr has joined #ponylang
droman_ has quit [Quit: WeeChat 2.1]
brainpro1 has quit [Quit: WeeChat 2.1]