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
kulibali has quit [Quit: Going offline, see ya! (www.adiirc.com)]
dougmacdoug has joined #ponylang
jemc has quit [Ping timeout: 255 seconds]
amclain has quit [Quit: Leaving]
_whitelogger has joined #ponylang
jemc has joined #ponylang
k0nsl has quit [Quit: “If we don't believe in freedom of expression for people we despise, we don't believe in it at all — Noam Chomsky”]
k0nsl has joined #ponylang
k0nsl has joined #ponylang
graaff has joined #ponylang
_whitelogger has joined #ponylang
endformationage has quit [Quit: WeeChat 1.7]
nyarum has joined #ponylang
jemc has quit [Ping timeout: 260 seconds]
dougmacdoug has quit [Quit: Page closed]
nyarum has quit [Ping timeout: 240 seconds]
smoon has joined #ponylang
Matthias247 has joined #ponylang
smoon has quit [Quit: smoon]
wintermoo has joined #ponylang
TheLemonMan has joined #ponylang
wintermoo has quit [Remote host closed the connection]
wintermoo has joined #ponylang
wintermoo has quit [Ping timeout: 240 seconds]
wintermoo has joined #ponylang
papey_lap has quit [Quit: WeeChat 1.8]
nyarum has joined #ponylang
wintermoo has quit [Remote host closed the connection]
wintermoo has joined #ponylang
wintermoo has quit [Ping timeout: 246 seconds]
nyarum has quit [Remote host closed the connection]
nyarum has joined #ponylang
nyarum has quit [Remote host closed the connection]
nyarum has joined #ponylang
nyarum has quit [Remote host closed the connection]
nyarum has joined #ponylang
jemc has joined #ponylang
wintermoo has joined #ponylang
wintermoo has quit [Ping timeout: 246 seconds]
nyarum has quit [Remote host closed the connection]
nyarum has joined #ponylang
nyarum has quit [Remote host closed the connection]
Matthias247 has quit [Read error: Connection reset by peer]
nyarum has joined #ponylang
aav has joined #ponylang
nyarum has quit [Ping timeout: 260 seconds]
wintermoo has joined #ponylang
wintermoo has quit [Client Quit]
<emilbayes> I find it a bit confusing what the idiomatic "byte" array is in pony. Is it String or Array[U8] or something else?
<jemc> emilbayes: you're not the only one - this is still a UX point that we want to work on
<jemc> I personally tend to use String for everything that *could* contain something that I want to print
<emilbayes> jemc: What's the overhead of String vs. Array[U8]?
<emilbayes> What if you know the size in advance and it is constant?
<emilbayes> jemc: I'm actually working on sodium again, and find the string type a bit awkward in the case of keys
<jemc> emilbayes: the performance overhead should be pretty much identical for all operations shared between the two types
<jemc> neither String nor Array provide any useful features for cases where the size of the buffer is constant, unfortunately - this would require the "dependent types" feature that Luke Cheeseman is working on to be finished
<emilbayes> jemc: Ah ok
<jemc> in general in Pony, without dependent types we can't have any types that are "aware of" values, like a constant-size buffer
<emilbayes> jemc: Which type would be more correct - if even possible - for the guarded heap allocations feature that sodium has? https://download.libsodium.org/doc/helpers/memory_management.html
<emilbayes> jemc: Ah ok, I don't mean for it to be enforced by the type checker. I just meant that I could declare that I know the size
<jemc> regarding guarded heap allocs: you're just wanting to use them for byte buffers, right? not to allocate arbitrary Pony objects in the guarded heap?
<emilbayes> jemc: Yeah, just for keys
<emilbayes> so byte arrays / buffers yeah :)
<jemc> regarding declaring a String or Array that you know the size of ahead of time: the constructors for both String and Array allow you to specify the expected number of bytes, and it will preallocate (some number at least as high as) that many bytes
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<emilbayes> jemc: Oh, that sounds good. I should read the stdlib for the two before asking more questions
<jemc> going back to guarded heap allocs: it would be fairly simple to call `sodium_malloc`, then pass it into a new String (or Array[U8]) with `String.from_cpointer`
<emilbayes> jemc: Ah, nice. How do I pevent pony from attempting to resize?
<jemc> the problem is that you'd have to explicitly call `sodium_free` as well
<jemc> so I'd recommend something like making a new wrapper class
<emilbayes> jemc: Yeah ok. There's no destructor / gc hooks?
<emilbayes> jemc: Oh yeah, I think it should be explicit that you're doing something fancy
<emilbayes> Because it also takes up a couple of pages of memory
<jemc> there is a hook, but you have to define it on the class that's being destroyed, and you can't define it on String
<emilbayes> jemc: Makes sense
<jemc> something like:
<jemc> (give me a sec to whip something up in a text editor)
<emilbayes> hehe kk!
<jemc> is this something you were thinking about doing a PR to my pony-sodium package on github?
<jemc> because I definitely like the idea
<emilbayes> Yes!
<jemc> note that by using a wrapper class, this also gives you the chance to "protect" the underlying array from being resized inadvertently
<emilbayes> jemc: For now I'm just doing my own small bindings for a small project (being inexperience with pony and all)
<emilbayes> jemc: Yes ok!
<jemc> you can also provide convenience methods to convert to/from array and string
<emilbayes> jemc: So there are a couple of things I thought I didn't like about how pony-sodium is currently structured, but maybe you can give some feedback on my ideas :)
<emilbayes> jemc: I thought the String types everywhere should be Seq[U8], but that doesn't make a difference, right?
<jemc> the problem with that is, some places are creating new Strings, and you can't call a constructor on a trait or interface
<jemc> however, we could adapt it to use type parameters - are you familiar with those yet?
<emilbayes> jemc: No not yet
<emilbayes> jemc: I should look it up
<jemc> so, to take the example of `CryptoHash`, we'd convert `primitive CryptoHash` to something like `primitive CryptoHash[A: Seq[U8] iso = String iso]`, then replace all uses of `String` with `A`
<jemc> it's probably going to be a bit more complicated to get the rcaps right, but the gist is that we'd make it generic, where you can pass in a different kind of `Seq` if you wish
<emilbayes> jemc: Oh, so how do I read that? CryptoHash is generic on A where A is ... what?
<jemc> A is the type of Seq that you want to using
<jemc> s/using/use/
<emilbayes> jemc: How do I read `Seq[U8] iso = String iso`?
<jemc> the general format for type params is pretty much the same as it is for normal params - `Name: Constraint` for a "normal" type param, and `Name: Constraint = Default` for an optional type param
<jemc> so, `A` is the parameter, `Seq[U8]` is the constraint, and `String` is the default
<emilbayes> So is String a type of Seq[U8]?
<jemc> gotta go, but I'll read the channel log when I get back if you have any more questions
<emilbayes> structurally or via inheritance?
<jemc> emilbayes: yeah, structurally
<emilbayes> jemc: Ok! thanks for all the help
<emilbayes> jemc: Will do a PR later with pwhash :)
jemc has quit [Ping timeout: 245 seconds]
pduncan has joined #ponylang
pduncan has quit [Ping timeout: 258 seconds]
Matthias247 has joined #ponylang
jemc has joined #ponylang
graaff has quit [Quit: Leaving]
jemc has quit [Ping timeout: 240 seconds]
jemc has joined #ponylang
Matthias247 has quit [Read error: Connection reset by peer]
jemc has quit [Ping timeout: 258 seconds]