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
<autodidaddict> in the playground, it looks like I can compare actors with "is" (e.g. firstConn is secondConn) and it only returns true on identity... so I'm assuming I can use that, but I'm so covered in newbsauce I don't know if that works because I'm doing something right or because I'm hopelessly confused :D
<autodidaddict> got it working... but it feels like it was too easy :D I certainly couldn't do this in Rust within a few hours of starting to read about the language
_whitelogger has joined #ponylang
autodidaddict has quit [Ping timeout: 260 seconds]
tj800x has quit [Quit: Page closed]
smoon has joined #ponylang
smoon has quit [Client Quit]
smoon has joined #ponylang
smoon has quit [Client Quit]
smoon has joined #ponylang
smoon has quit [Client Quit]
<SeanTAllen> Tags are unique autodidaddict
<SeanTAllen> Is indeed compares identity
<SeanTAllen> People often get tripped up and do:
<SeanTAllen> foo is String
<SeanTAllen> Which creates a new string and compares it to foo for identity
<SeanTAllen> Not what they wanted?
<SeanTAllen> No ? Should have been on that. My phone autocorrected
TheNet has joined #ponylang
<SeanTAllen> A new "Last Week in Pony" is out... https://www.ponylang.org/blog/2017/07/last-week-in-pony---july-9-2017/
TheNet has quit [Quit: Textual IRC Client: www.textualapp.com]
bitcrusher has quit [Read error: Connection reset by peer]
_whitelogger has joined #ponylang
Matthias247 has joined #ponylang
papey_lap has joined #ponylang
papey_lap has quit [Ping timeout: 260 seconds]
Praetonus has joined #ponylang
<Praetonus> SeanTAllen: I'm thinking we should issue a compiler error for that
<Praetonus> Limiting it to non-primitive constructors that use the create sugar shouldn't catch legitimate cases
<Praetonus> Constructor calls rather than constructors
autodidaddict has joined #ponylang
autodidaddict has quit [Ping timeout: 260 seconds]
smoon has joined #ponylang
autodidaddict has joined #ponylang
<autodidaddict> Another odd question ... I can definitely use TCPConnection with an "is" comparison .. but I can't use it as a key in a map. I want to create an actor representing a connected client (e.g. Player). I have a conn mgr actor that needs to keep track of all connected clients
<autodidaddict> I figured easiest way to do that would be Map[TCPConnection, Player] ... so that when my TCP notifier gets a notification from a TCPConnection, I can quickly look up the corresponding player actor and send the message along
smoon has quit [Quit: smoon]
<autodidaddict> I'd like to avoid maintaining two arrays and just matching by index
<Praetonus> autodidaddict: Map compares key by structural equality (the eq method), which requires read access. You need MapIs, which compares by identity
<autodidaddict> MapIs is a type? That's freaking spectacular
<Praetonus> Both Map and MapIs are alias on the HashMap collection with different comparison functions
<Praetonus> If you ever need a map with a custom comparison function, you can use HashMap directly
<autodidaddict> nice. Now for the really stupid question - how do I get the size of the map, .e.g. number of keys?
<Praetonus> That's map.size()
<autodidaddict> hah. I'm overthinking this. It's never that easy
<autodidaddict> other languages usually force me to get the keys as an array, then query the array length
<autodidaddict> :P
<autodidaddict> I can't believe this works.
<autodidaddict> It's supposed to be much more difficult :)
<autodidaddict> At this point in a similar Rust project, with several weeks more learning time, I'd thrown in the towel
<Praetonus> Glad you're having a good learning experience with Pony. We're still trying to improve the experience for new users so there are some rough edges left
<autodidaddict> Getting a blog post ready to cover my thoughts on this.
<autodidaddict> also - is there a version of trim() that removes trailing whitespace? I'm trying to remove the trailing \n\r from a user-entered string
<autodidaddict> but I don't want to have to write the code to detect if it's a \r or a \n\r or a \n
<Praetonus> I think there is, let me check
<Praetonus> It's rstrip for trailing whitespace, lstrip for leading whitespace, and strip for both
<autodidaddict> ok. I'm finding the stdlib docs very difficult to navigate
<autodidaddict> "receiver type is not a subtype of target type let cmd = String.from_array(consume data).rstrip() ^"
<autodidaddict> this feels like I'm missing something obvious
<autodidaddict> oooh looks like rstrip mutates rather than returns
<Praetonus> Yes
<autodidaddict> is there a design choice for mutating rather than returning?
<Praetonus> We usually have both, with `method` doing a copy and `method_in_place` modifying in place
<Praetonus> I think not having this pattern for strip is an oversight
<Praetonus> By the way if the Array you're creating the String from is an iso, you can use String.from_iso_array, which will create a mutable String
<autodidaddict> I must be reading the docs wrong
<autodidaddict> var cmd: String = String.from_array(consume data) String.rstrip(cmd)
<autodidaddict> this doesn't appear to do anything
<autodidaddict> It's staggering how much i used to rely on autocomplete to learn a new language. Not having it makes me feel teh dumbz
<Praetonus> `String.rstrip(cmd)` is sugared to `String.create().rstrip(cmd)`
<Praetonus> That would strip the characters in cmd from an empty string
<autodidaddict> so what's the syntax to strip the whitespace from cmd?
<Praetonus> cmd.rstrip()
<autodidaddict> that's where I get this ": receiver type is not a subtype of target type cmd.rstrip()"
<Praetonus> Yes, because as you saw earlier, rstrip needs a mutable String
<autodidaddict> I thought `var` made my string mutable
<autodidaddict> I used `from_iso_array` and I still get that receiver error
<autodidaddict> var cmd: String = String.from_iso_array(consume data) cmd.rstrip()
<Praetonus> var and let affect whether a variable name can be rebound to another reference
<Praetonus> But mutability depends on reference capabilities: iso, trn and ref are mutable
<Praetonus> Your problem with from_iso_array comes from the type that you're declaring for cmd
<Praetonus> When you write `String` as a type, this is translated to `String val` because the default capability for String is val
<Praetonus> So even though from_iso_array returns a mutable String, that mutability is lost when the reference is assigned to cmd
<autodidaddict> ahhh ok.
<autodidaddict> that did the trick. Apologies for the newbsauce... only been reading about Pony for a few hours
<Praetonus> No problem
<autodidaddict> this is what I ended up with:
<autodidaddict> let cmd = String.from_iso_array(consume data) cmd.rstrip() _cm.cmdreceived(conn, consume cmd)
<autodidaddict> the last line is sending to an actor behavior
<autodidaddict> The reference capability stuff really is brilliant. I keep finding subtle ways that it helps without getting in my way (like preventing me from invoking a synchronous method defined on an Actor from outside the actor)
<autodidaddict> Whereas Rust's borrow checker is always smashing me in the face with a hammer
endformationage has joined #ponylang
papey_lap has joined #ponylang
autodidaddict has quit [Ping timeout: 260 seconds]
<SeanTAllen> @Praetonus i like the compiler error idea. a lot.
<SeanTAllen> autodidaddict: the standard lib docs could use some loving. they were originally designed so that you could generate docs for amy pony codebase (still can) using mkdocs. i think mkdocs works well for smaller codebases but for standard library, its not so great. if you have ideas on a better way to present the std library docs, drop me an email at sean@monkeysnatchbanana.com and lets talk. simple wireframes etc would be a
<SeanTAllen> great way to lead into the conversation.
<SeanTAllen> autodidaddict: you are doing quite well and we aim to be a community where people, no matter what their level of experience, aren't afrained to ask "newbie" questions. as we see it, usually it means we need better documentation, better tutorials to guide folks etc. ask away!
autodidaddict has joined #ponylang
<autodidaddict> @SeanTAllen thanks for the info. I've been keeping notes on things, I'll send some thoughts to you
<SeanTAllen> i considered replacing it but... to really get some good stuff going, ive been waiting for the pony in pony compiler which is slow going. it would be nice to keep doc generation as something that works for any project. i think that can be maintained, just not using mkdocs. maybe just boring old markdown with links and the ability to generate indexes for different tools. not sure. maybe say "you have to use hugo with this"
<SeanTAllen> ¯\_(ツ)_/¯
<SeanTAllen> i gave the material docs hugo theme a try but it also doesnt hold up well with larger codebases (same as mkdocs). new approach is definitely needed.
autodidaddict has quit [Ping timeout: 260 seconds]
<Praetonus> SeanTAllen: I'll open an issue for the compiler error on `is`
TheNet has joined #ponylang
TheNet has quit [Client Quit]
endformationage has quit [Read error: Connection reset by peer]
endformationage has joined #ponylang
TheNet has joined #ponylang
endformationage has quit [Quit: WeeChat 1.7]
<SeanTAllen> Awesome
<SeanTAllen> Thanks
TheNet has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vaninwagen has joined #ponylang
tj800x has joined #ponylang
TheNet has joined #ponylang
<tj800x> Hi guys. I just posted my first chapter of my "Grokking Pony" book.
<tj800x> It's at https://tj800x.github.io./
<tj800x> Issues welcome on the Github.
<tj800x> It's just a start, but puts some language to that analogy idea I posted yesterday.
<tj800x> Not all the formatting went across. I'll have to figure that out. I saw a couple of new typos. Also, the analogy needs to be simplified. This is complex to explain this way.
tj800x has quit [Ping timeout: 260 seconds]
obadz has quit [Ping timeout: 240 seconds]
obadz has joined #ponylang
endformationage has joined #ponylang
TheNet has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
TheNet has joined #ponylang
papey_lap has quit [Ping timeout: 255 seconds]
smoon has joined #ponylang
<SeanTAllen> Small thing tj800x: I'd like to suggest using standard library formatting for code samples
_whitelogger has joined #ponylang
smoon has quit [Quit: smoon]
smoon has joined #ponylang
vaninwagen__ has joined #ponylang
vaninwagen has quit [Ping timeout: 260 seconds]
vaninwagen__ has quit [Ping timeout: 240 seconds]
tj800x has joined #ponylang
<tj800x> Sean, good suggestion. Is there a spec or should I just look through the libraries. In the first draft I really wasn't paying any attention to formatting.
<endformationage> Regarding the ffi-struct example found here: https://github.com/ponylang/ponyc/blob/master/examples/ffi-struct/struct.pony#L35
<endformationage> Am I correct to say this example needs to be updated to use `MaybePointer[Outer]` as described in the Tutorial here: https://tutorial.ponylang.org/c-ffi/calling-c.html (Read struct values from FFI section)
<endformationage> ... when passing `s` to the FFI function @modify_via_outer and @modify_inner
<Praetonus> endformationage: I think it's the tutorial that is a bit off
<Praetonus> MaybePointer is useful as a return type for FFI functions returning possibly null structs
<Praetonus> But as an argument it makes no difference
<Praetonus> Unless you actually need to pass NULL to the function, that is
smoon has quit [Quit: smoon]
Matthias247 has quit [Read error: Connection reset by peer]
<endformationage> Ah, alright thanks.
TJ800X21 has joined #ponylang
tj800x has quit [Ping timeout: 260 seconds]