nisanharamati has quit [Quit: Connection closed for inactivity]
bpicolo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Bombe has joined #ponylang
TheMouster has joined #ponylang
gokr has quit [Ping timeout: 260 seconds]
<TheMouster>
Can someone explain this error for me?
<TheMouster>
Error: /home/greg/Documents/Solutions/DiamondKata/diamonkata.pony:28:27: receiver type is not a subtype of target type _result.append(_spaces(i)) ^ Info: /home/greg/Documents/Solutions/DiamondKata/diamonkata.pony:28:13: receiver type: String val _result.append(_spaces(i)) ^ /usr/lib/pony/0.20.0-4003.0b2a2d2/packages/builtin/string.pony:800:3: targe
<TheMouster>
OK. That didn't work as well as I thought it might.
<TheMouster>
Basically I've got a function that generates a string of spaces given a number, and I'm appending the result of the function to a string, but I'm getting the reciever type is not a subtype of target type error upon compilation and nothing I've tried so far has had an appropriate effect. Thanks.
<SeanTAllen>
Hi TheMouster
<SeanTAllen>
Can you send a gist to pony playground with your function/class?
<TheMouster>
Hi Sean, I had a look at the error message guide and it, unfortunately, didn't assist me. Need more knowledge. :-). I'll make a gist and put it up.
<TheMouster>
Hi Sean, You're one helpful dude! Respect. Thanks for the input. I shall continue my learning adventure.
TheMouster has quit [Ping timeout: 260 seconds]
<SeanTAllen>
Glad to help.
wizeman has quit []
digdug_ has quit [Remote host closed the connection]
digdug__ has joined #ponylang
dipin has joined #ponylang
jemc has quit [Ping timeout: 248 seconds]
dipin has quit [Quit: dipin]
endformationage has quit [Quit: WeeChat 1.9.1]
gokr has joined #ponylang
enilsen16 has joined #ponylang
samuell has joined #ponylang
gokr has quit [Ping timeout: 255 seconds]
enilsen1_ has joined #ponylang
doublec_ has joined #ponylang
enilsen16 has quit [Ping timeout: 248 seconds]
doublec has quit [Ping timeout: 248 seconds]
samuell has quit [Remote host closed the connection]
samuell has joined #ponylang
doublec_ is now known as doublec
gokr has joined #ponylang
TheMouster has joined #ponylang
aturley has joined #ponylang
enilsen16 has joined #ponylang
enilsen1_ has quit [Ping timeout: 264 seconds]
<TheMouster>
Hi, Can someone, not necessarily Sean, who has been most helpful, but probably needs a rest, explain what the meaning is of the greater-than symbols in this; _result.>append("B").>append("\n")
<TheMouster>
I've hunted around in the documentation but I've not come across it.
Praetonus has joined #ponylang
<TheMouster>
Also, is it possible to define my own apply function for my own classes? It appears it's not as straight-forward as just adding an apply function to my object. Tks.
bpicolo has joined #ponylang
aturley has quit [Quit: aturley]
<TheMouster>
So many little questions.... apologies. How do I convert a U8 into a character? i.e. 65 = A, 66 = B etc.
<TheMouster>
Just realised I missed Sean's comment on chaining. Ignore my question about the .>. I know what it is now.
<SeanTAllen>
TheMouster: Yes you can add your own apply function to your objects. Its as straightforward as adding your own apply method.
<SeanTAllen>
TheMouster: Pony doesn't have a char type. When you say convert, do you mean for printing the ascii code?
<TheMouster>
Evening/morning @Sean. Yes for printing the related letter ie 65 UTF-8/Ansi/ASCII is A
<TheMouster>
That said, it would also be most helpful to get the character number for a given character i.e. A => 65.
<TheMouster>
I may be able to help myself with regards to the last question, I've just found character literals in the doco.
<TheMouster>
Scratch that, still need assistance. The character literals aren't quite behaving as I'd expect.
enilsen16 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
TheMouster has quit [Ping timeout: 260 seconds]
<gokr>
Btw, method chaining like that is called a cascade in Smalltalk. Not sure it's helpful though, since most people have no idea about Smalltalk ;)
<gokr>
I am studying Pony btw, it's very interesting and I am taking notes to write a blog article about it.
dipin has joined #ponylang
bpicolo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
trevorriles has joined #ponylang
<SeanTAllen>
TheMouster: how were you expecting character literals to behave?
jemc has joined #ponylang
trevorriles has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
trevorriles has joined #ponylang
gokr has quit [Ping timeout: 246 seconds]
nisanharamati has joined #ponylang
enilsen16 has joined #ponylang
enilsen16 has quit [Read error: Connection reset by peer]
trevorriles has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bpicolo has joined #ponylang
trevorriles has joined #ponylang
endformationage has joined #ponylang
jemc has quit [Read error: Connection reset by peer]
aturley has joined #ponylang
enilsen16 has joined #ponylang
aturley has quit [Client Quit]
wizeman has joined #ponylang
enilsen16 has quit [Read error: Connection reset by peer]
gokr has joined #ponylang
enilsen16 has joined #ponylang
enilsen16 has quit [Read error: Connection reset by peer]
jemc has joined #ponylang
enilsen16 has joined #ponylang
dougmacdoug has joined #ponylang
enilsen1_ has joined #ponylang
enilsen16 has quit [Read error: Connection reset by peer]
trevorriles has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
user10032 has joined #ponylang
aturley has joined #ponylang
trevorriles has joined #ponylang
aturley has quit [Quit: aturley]
enilsen1_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gokr has quit [Ping timeout: 240 seconds]
enilsen16 has joined #ponylang
<endformationage>
Hello. I'm playing with the DNS primitive from the 'net' package. Is ist normal to get multiples of the same (as far as I can tell) NetAddress returned?
<endformationage>
I want to include logging in my pony library. Is there any sort of convensions to adding a prefix to log messages or the like?
<SeanTAllen>
i dont believe so
<SeanTAllen>
have you seen the logger package in stdlib?
<endformationage>
Yes, I've used it.
<SeanTAllen>
k
<endformationage>
.. although I had trouble using the StringLogger before. I Don't remember why but I had to reconstruct as a Logger[String]. I will try again.
<endformationage>
Anyhow, I thought I'd just accept a StringLogger to the entry point of my lib, and perhaps prefix with the lib's name, log level in some fashion.
<SeanTAllen>
hmm works for, StringLogger that is
doublec has quit [Changing host]
doublec has joined #ponylang
theodus has joined #ponylang
nerfpops has joined #ponylang
theodus has quit [Client Quit]
<nerfpops>
hi! I'm calling a function from C that returns `typedef enum { CONNECTION_OK, CONNECTION_BAD } ConnStatusType` ... I can figure out how to intercept that from Pony.
<jemc>
nerfpops: C99 standard says that when there are no explicit number assignments in an enum, they start from `0` and go up
<nerfpops>
using `primitive ConnectionOk \n primitive ConnectionBad \n type ConnStatusType is (ConnectionOk | ConnectionBad)` and calling `@PQstatus[ConnStatusType](conn)` results in a segfault
<jemc>
so I'd do it something like `let success: Bool = (0 == @PQstatus[I32](conn))`
<jemc>
note that the type union of primitives approach you gave above gives you something *analogous* with an enum, but not directly compatible with one
<jemc>
C enums should just be treated as `I32` from Pony's perspective
<nerfpops>
excellent. Thank you for your quick help
<jemc>
no problem~
trevorriles has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dipin has quit [Quit: dipin]
<gokr>
I know it's just a silly syntactic thing - but I have to ask anyway. A lot of the grammar seems to be indentation based - like class or actor declarations, and methods. But ... if then end, recover end, loops etc, instead follow the more verbose keyword style. I am just curious over the reasoning behind that.
bpicolo has joined #ponylang
user10033 has quit [Quit: Leaving]
dipin has joined #ponylang
<jemc>
gokr: the grammar actually isn't indentation-based - the similarity to indentation-based grammars is a bit of an illusion
<gokr>
Yeah, I kinda suspected that - but... well.
<gokr>
It's convention I guess.
<jemc>
whenever the parser encounters a keyword like `class`, it knows that a new class is being declared, thus is knows the current class must be over
<gokr>
right.
<gokr>
I kinda suspected it wasn't indentation based - that the grammar was enough to not need that - but it still reads like it.
<jemc>
but yeah, for constructs where we have `end` it's because that's not really possible
<gokr>
Again, I am used to many different syntaxes, so not complaining per se - just curious.
<jemc>
I wasn't around at the inception of the pony syntax, but I think it was just a desire to avoid `end` where possible, but not being able to acheive it everywhere
<jemc>
if it were me designing the language from scratch, I probably would have used curly braces for all scope-like constructs
<gokr>
And possibly "save" the {}[] for other uses?
<gokr>
In my lang (sprylang.org) I consciously "saved" those for literal arrays and maps, perhaps same idea here?
<gokr>
Oh, right - {} is closure in pony.
<jemc>
it is now, but that was a change that I pushed for during my time
<gokr>
Hehe
<jemc>
it used to be `lambda() ... end`, but I pushed for the more concise syntax
<gokr>
I agree that closures/lambdas should ideally to be lightweight syntactically.
<gokr>
How are things going with the ponyc-in-pony btw?
<gokr>
Btw, regarding things causing "confusion" for n00bs like me - I would argue some terminology is... oddish. The tutorial should IMHO be modified to explain why things have the names they have.
<gokr>
Or I mean, not modified - but complemented.
<gokr>
It's much easier mentally if I know what to "read in my mind" when I see "trn" for example.
<gokr>
I think that one is just thrown out there - and I suspect it's short for "transitional" as in about-to-become-a-val.
<jemc>
I usually end up saying "tran" for short
<gokr>
Another of these "weird names" is recover.
<gokr>
I am right now scanning around trying to find a reasonable mental model of "something lost that was now recovered".
<gokr>
But... I don't really get it all to fit.
<gokr>
I think we are talking about "recovering capabilities denied to others", but...
jtarchie has joined #ponylang
<jtarchie>
Hi, all! I have a question about using match with a union type. Will the compiler complain if all types in the union are not represented in the match?
<jtarchie>
This is something similar to what elm-lang does?
<gokr>
seems so, reading tutorial
<SeanTAllen>
i thought it should be, but I just created a match statement that doesn't
dougmacdoug has left #ponylang [#ponylang]
<jemc>
jtarchie: the compiler *won't* complain about the lack of representation in the match, because an incomplete match is sometimes desirable (at least in a language like pony that isn't pure FP)
<jemc>
however, you *will* usually get compiler errors if you're relying on the return value of that match, because the compiler inserts an implicit `else None` in a non-exhaustive match
<jemc>
so the type of the match expression result becomes `(TheTypeYouProbablyWanted | None)`
<jemc>
but an incomplete match can often be useful in imperative code, in the same way that an `if` block without an `else` can often be useful
<jtarchie>
jemc: thanks for the clarifying
<SeanTAllen>
i think it would be nice to have an option to make a match complete jemc. thoughts?
<jemc>
SeanTAllen: what do you mean by "an option"?
<jtarchie>
I've found the pattern in elm-lang with union types to be really useful.
<jtarchie>
I was curious if other compiled languages (that are not Haskell) provided the same functionality.
<SeanTAllen>
jemc some way to say "this match should throw an error if it isn't complete"
<jemc>
SeanTAllen: like, via syntax?
<SeanTAllen>
i wasn't paying that much attention when exhaustive match went in jemc.
<SeanTAllen>
that, what i thought it was.
<SeanTAllen>
error if not complete
<SeanTAllen>
jemc, i would imagine via syntax yes
<jemc>
SeanTAllen: yeah, that could make sense
<jemc>
I was hoping you didn't mean compiler flag :)
<SeanTAllen>
o god no
<SeanTAllen>
ya syntax
<SeanTAllen>
i would very much like that
<SeanTAllen>
complete matching with union types can be wicked helpful and powerful
<SeanTAllen>
the ability to do incomplete can be nice as well
<jemc>
agreed
<SeanTAllen>
im a runtime person though. i'll have to get one of you compiler folks to do it.
<SeanTAllen>
;)
wizeman has quit [Quit: Connection closed for inactivity]
<jemc>
the hardest part will just be picking a sane syntax
kulibali has quit [Quit: Going offline, see ya! (www.adiirc.com)]
TheMouster has joined #ponylang
<TheMouster>
Morning/evening How can I get the length of a string in characters as opposed to bytes? And how can one use the trim function to trim a string from the 2nd character to the end of the string? Tks.
bpicolo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<TheMouster>
Also, if an input to my function is "D" how can I iterate from "A" to "D"? Apologies for all the weird questions. Just trying to get a handle on the language.
<TheMouster>
At a simplistic level to start with.
<jemc>
TheMouster: no need to apologize, we're happy to help you get things figured out
<jemc>
for starters, I just wanted to mention that the String API isn't as nice as we'd like it right now, and we're trying to get it redesigned to account for some pain points
<jemc>
that said, I think what you're asking is definitely possible with the current API
<jemc>
let me take a quick look
TheMouster has quit [Ping timeout: 260 seconds]
<jemc>
hm, actually - it may not be possible, depending on what you mean by "characters" - it can count/iterate over multi-byte codepoints, but does not handle multi-codepoint characters, for cases where codepoints can contribute to a single character
<endformationage>
SeanTAllen: Found that my prior problem with StringLogger was confusing it with a Logger itself, attempting to accept `logger: StringLogger` as a Logger instance, but of course StringLogger is a primitive.
<SeanTAllen>
glad you figured it out endformationage
<SeanTAllen>
TheMouster: I don't understand this question, sorry: Also, if an input to my function is "D" how can I iterate from "A" to "D"? Apologies for all the weird questions. Just trying to get a handle on the language.
<nerfpops>
I've got to the part where I need to create an input_mask and call FD_ZERO and FD_SET
<SeanTAllen>
nerfpops: you'd want to register the file descriptor with the async io system and implement the event handling
<SeanTAllen>
if you take a look at TCPConnection, you can see how its done
<nerfpops>
thanks, I'll look into that
<jemc>
yeah, I was about to tell you something similar
<SeanTAllen>
in particular see `@pony_asio_event_create`
<jemc>
though I think looking at the `Stdin` actor may be a simpler example
<SeanTAllen>
there's a bunch of use @pony_asio_event_* those are all the asio support method it uses
<SeanTAllen>
true Stdin might be easier
<SeanTAllen>
we should probably create a primitive to make setting up asio event handling easier jemc, although i'm not sure what to do about the event_notify behavior. maybe it would be a trait. hmmm...
<jemc>
yeah, I've had the same thought on several occasions - having some kind of abstraction to make this easier would be nice
<jemc>
maybe something like `Timer` + `Timers`, but for file descriptors?
<SeanTAllen>
It would take some work to get right, but ya
<SeanTAllen>
At least as a way to easy people into doing async io
<nerfpops>
auch yeah that seems hard.. any documentation for a newb?
<SeanTAllen>
nerfpops: sadly no, not at this time. it's on my really long list of things to do.
<SeanTAllen>
the important parts are the @pony_asio_event_create, that will create an event.
<SeanTAllen>
are you doing reads, writes?
<nerfpops>
only reads at this time
<nerfpops>
probably only reads
<SeanTAllen>
ok so how STDIN creates the event. that is what you want.
<jemc>
the stuff in the `_read` function would get replaced by your PQConsume call
<SeanTAllen>
then if you do what STDIN has in _event_notify() you are good
<nerfpops>
thanks!
<SeanTAllen>
its not hard once you know what is going on but its tough to get started.
<SeanTAllen>
jemc: i'll try to make time to add something about working with Asio when I'm done with runtime backpressure.
<SeanTAllen>
I'm thinking that's an "existing user" website section rather than tutorial. Thoughts?
<SeanTAllen>
Seems a little advanced for tutorial and potentially overwhelming
<SeanTAllen>
nerfpops: if you get stuck, feel free to post a gist here and we can try to help more.
<nerfpops>
will do
<SeanTAllen>
btw, nerfpops we have a blog series of "early impressions" from new Pony users. If you take notes on what was hard for you, what was easy, and want to do a post in 2 or 3 weeks, email me at sean@monkeysnatchbanana.com and we can talk more.