<SeanTAllen>
something might have changed from when you did it. there are conflicts against master though. TwoNotes.
prettyvanilla has joined #ponylang
prettyvanilla_ has quit [Ping timeout: 258 seconds]
graaff has joined #ponylang
rurban has left #ponylang [#ponylang]
jemc has quit [Ping timeout: 276 seconds]
TonyLo has joined #ponylang
rurban has joined #ponylang
graaff has quit [Quit: Leaving]
rurban has left #ponylang [#ponylang]
k0nsl_ has quit [Ping timeout: 256 seconds]
k0nsl has joined #ponylang
k0nsl has joined #ponylang
k0nsl has quit [Changing host]
k0nsl has quit [Ping timeout: 252 seconds]
k0nsl has joined #ponylang
k0nsl has quit [Changing host]
k0nsl has joined #ponylang
<TonyLo>
given: let terms = ["cat", "dog"] how do I make the array sendable? e.g. Array[String val] val rather than the current Array[String val] ref. (I struggle with arrays currently)
<TonyLo>
The receiver looks like this: be processTask(term: String, terms: Array[String] val) =>
Matthias247 has joined #ponylang
_andre has joined #ponylang
aav_away has quit [Ping timeout: 276 seconds]
mrkishi has quit [Ping timeout: 240 seconds]
rurban has joined #ponylang
<doublec>
TonyLo: let terms = recover val [ "cat", "dog" ] end
<TonyLo>
doublec, duh, what was I thinking! thx
aav_away has joined #ponylang
seanohue has joined #ponylang
aav_away is now known as aav
seanohue has quit [Ping timeout: 256 seconds]
c355e3b has joined #ponylang
TwoNotes has joined #ponylang
rurban1 has joined #ponylang
rurban has quit [Ping timeout: 240 seconds]
rurban1 has quit [Quit: Leaving.]
<dougmacdoug>
if I have a member variable String ref and I want to send it (i.e. to print) is there a better way than str.string() ? or is that standard?
jemc has joined #ponylang
TwoNotes has quit [Ping timeout: 245 seconds]
jemc has quit [Client Quit]
jemc has joined #ponylang
<SeanTAllen>
send to env.out ?
<SeanTAllen>
you can't send a ref
<SeanTAllen>
you would need to make a copy of it, there's no standard way to do that. but i believe str.string() would work
TwoNotes has joined #ponylang
<dougmacdoug>
thanks, thats what i meant.. just wondering if clone() or some other thing was standard
<SeanTAllen>
jemc might have thoughts, but as far as i'm aware, there is no idiom around that
ivan has joined #ponylang
inara has joined #ponylang
<TwoNotes>
Are all the stdlib style guidelines written in one place?
<SeanTAllen>
not at the moment, it comes from being familiar with it and checking out how things are done
<SeanTAllen>
checking out a couple different classes should give a good feel @TwoNotes
<SeanTAllen>
many people have said they would do a style guide but it hasnt happened yet
<SeanTAllen>
i never volunteered because i knew i wouldnt have time with work to tackle that
<TwoNotes>
Well, all the ones I looked at show => on the sam eline as the function def. But you say it should be separate
<SeanTAllen>
example?
<TwoNotes>
packages/builtin/array
<SeanTAllen>
where specifically?
<TwoNotes>
Every fun def in that file
<SeanTAllen>
you misunderstood me
<SeanTAllen>
see line 209
<TwoNotes>
yes
<SeanTAllen>
when you do a multiline for parameters
<SeanTAllen>
=> should be at the same level as `fun`
<SeanTAllen>
like copy_to
<SeanTAllen>
this is only for multiline
<TwoNotes>
Oh, so IF the parameters themselves wrap, THEN the arrow goes on the next line..
<SeanTAllen>
yes
<TwoNotes>
Otherwise it goes to the right of the )
<SeanTAllen>
sorry
<SeanTAllen>
yes
<SeanTAllen>
i wasnt clear
<TwoNotes>
ok
<SeanTAllen>
if you find places in the standard library that dont do that
<SeanTAllen>
PRs are welcome
<SeanTAllen>
i found 1 in Array already
<SeanTAllen>
line 60
<SeanTAllen>
and 378
<TwoNotes>
And am I right that 'then', 'else', 'end' all go at the same indent as the 'if or 'try' that starts the phrase?
<SeanTAllen>
which i am going to pr now
<SeanTAllen>
yes
<SeanTAllen>
well no
<TwoNotes>
And the contents then go 2 spaces further in
<SeanTAllen>
then goes at the end of the line with if
<TwoNotes>
ok
<SeanTAllen>
else and end going on same level of indentation
<SeanTAllen>
ya, 2 spaces for indentation
<TwoNotes>
Same would apply to 'match'?
<SeanTAllen>
match
<SeanTAllen>
the
<SeanTAllen>
| something
<SeanTAllen>
goes under the match
<TwoNotes>
else and end too
<TwoNotes>
Does the emacs macro help with this? I have a very old one
<SeanTAllen>
i dont think emacs helps with it
<SeanTAllen>
i did some small tweaks when i took it over
<SeanTAllen>
but it needs a large overhaul
<SeanTAllen>
listener.pony line 50 is a good example of a multimatch formatting
<SeanTAllen>
and ring/main.pony line 52 is a good example of match in general
<SeanTAllen>
there is currently no standard on whether one liners after a match should go on next line or same line as the =>
<SeanTAllen>
btw
<SeanTAllen>
TwoNotes one of my comments was wrong
<TwoNotes>
which?
<SeanTAllen>
lots of the standard library has ) on a line by itself after long multilines
<TwoNotes>
For example, replacing a single line use of "+" to concatenate strings, with something 14 lines long using append, for example
<TwoNotes>
The suggested style of adding up all the lengths first , allocating, then appending, sounds like a good optimization the compiler could do
<TwoNotes>
in place of str = a + b + c
Praetonus has joined #ponylang
<Praetonus>
TwoNotes: The compiler can already do that
<Praetonus>
There may be specific cases that it doesn't cover, it would be best to check the generated IR to see if your use case is covered
<Praetonus>
Though if it's not covering something as simple as string concatenation, I'd say it's a bug
<SeanTAllen>
Praetonus: according the Sylvan, the sugar pass does not handle that
<SeanTAllen>
and + is sugar. for add
<SeanTAllen>
that + results in multiple memory allocations as it does each individual memory call
<Praetonus>
Yes, but the custom LLVM passes that we have can do that
<SeanTAllen>
I dont believe they do
<SeanTAllen>
I am going to stand by my statement that any string concat in performance critical code should be replaced with usage of append until the compiler hands that
<SeanTAllen>
rule 1: correctness
<SeanTAllen>
rule 2: performance
amclain has joined #ponylang
<Praetonus>
I just checked, it's not working because the allocations in String.add aren't inlined due to the size of the function
<Praetonus>
That's kinda disappointing, we'll have to do some work in that area
TonyLo_afk has joined #ponylang
TonyLo has quit [Ping timeout: 240 seconds]
rurban has joined #ponylang
<SeanTAllen>
Praetonus: can you open an issue to for that?
<Praetonus>
I'll do it
<SeanTAllen>
thanks
<SeanTAllen>
you are much better position to write a good issue than i am
<TwoNotes>
It would have to make two passes over the strings, thr first to add up the lengths and the second to call append
<Praetonus>
TwoNotes: That would be too specific. The current pass works directly on calls to the `pony_alloc` and `pony_realloc` from the runtime. The problem here is that it can't see everything at once because the calls to append aren't inlined
<TwoNotes>
There is now higher level optimization pass before that??
<TwoNotes>
no*
<TwoNotes>
Things like moving invariant expressions out of loops
<Praetonus>
Not currently. The Pony AST isn't the best data structure for optimisation passes
<TwoNotes>
These would be pattern matches on the syntax tree, before the code generation phase
<Praetonus>
And LLVM is very good at this kind of optimisations
<TwoNotes>
When I worked on a compiler 40 years ago (omg, Im old) it did that sort of optimization
<TwoNotes>
It was called the "Flow Optimization" pass
<TwoNotes>
But doing the trick with concat by append is sort of specific to Pony semantics, so LLVM wouldn't know about it
<Praetonus>
I think it's an area open to investigations
<Praetonus>
If somebody wants to dig into it and setup a framework for AST optimisations, it would be very welcome
rurban has left #ponylang [#ponylang]
TonyLo_afk is now known as TonyLo
Praetonus has quit [Quit: Leaving]
TwoNotes has quit [Quit: Leaving.]
<jemc>
doing some high-level (AST) substitutions like that could be interesting, and possibly useful, but the low-level (LLVM IR) are far more general, if we can get them working well
<jemc>
so if done right, they would apply to far many more cases than just `string + string`, without introducing a bunch of special cases at the high level
<jemc>
so I'd agree with Praetonus that its an item we'd want to look at first (or at least in parallel)
<aav>
it's not possible to pattern match against interface, right?
<aav>
i mean, use interface as a pattern
<jemc>
aav: it is possible - you just need to make sure you're using a `let` clause
<aav>
i have such function in the decoder - fun decode(wttag: U32): ((WireType val, U32) | InvalidTag)
<jemc>
for example, `match foo | let f: MyInterface => f.my_interface_method() end`
<aav>
WireType is interface
<aav>
interface WireType
<aav>
fun code(): U32
<aav>
match decoder.decode(u32)
<aav>
h.fail("Invalid Tag")
<aav>
| InvalidTag =>
<aav>
None
<aav>
| (WireType, U32) =>
<aav>
end
<aav>
| (let x: WireType, U32) =>
<aav>
does not work as well
<jemc>
you need something like `(let x: WireType, let y: U32)`
<aav>
(let x: WireType val, let y: U32)
<aav>
this worked
<aav>
i'm still confused with default capabilities
<aav>
and related question - what if i'm not interested in U32 value?
<aav>
i simply want to be sure it's U32
<aav>
or, not even U32, just anything
<aav>
like _ in erlang
<jemc>
there's an open ticket discussing the possibility of allowing `_` in match clauses
<jemc>
I think it was seen as generally be desirable, but it had some technical issue that needed to be solved first, if I recall correctly
TonyLo_afk has joined #ponylang
TonyLo has quit [Ping timeout: 240 seconds]
<jemc>
aav: actually, I'm wrong - using `_` was implemented, but you still needed to specify the type
<jemc>
so, something like `(let x: WireType, let _: U32)`
<jemc>
using that feature is probably the best bet for making the syntax pleasant to work with
<aav>
makes sense
<aav>
and how about varargs?
<aav>
and/or heterogeneous array literals
<jemc>
I don't necessarily think that varargs are a good fit for Pony, since it would really step outside the domain that the type system was designed for
<jemc>
I was going to suggest something more akin to a "factory" pattern, where additional parts of the message are supplied through additional function calls
<jemc>
however, such a system *does* have the potential to be harder to optimize - not sure how much the performance of the calls matter for most use cases, though
TonyLo has quit []
<aav>
type Formattable is (U8 | String)
<aav>
Printf("Hello, World - %s %d", [as Formattable: "123", 4])
<aav>
""
<aav>
fun apply(format: String, args: Array[Formattable]): String =>
<aav>
primitive Printf
<aav>
something like this would help. perhaps type inference for function arguments will help with verbose array literal
<jemc>
yes, something like that could work, though note that the type system can't be used to verify that the argument correlated with the format code have "matching" types
<jemc>
also, removing the need for `as Formattable` in that context is also on my list for inference improvements, though it's not quite part of the same ticket
<aav>
jemc: of course, this has to checked in runtime.
<jemc>
using positional, type-agnostic format specifiers could be one possible solution (similar to a Qt C++ API I remember seeing somewhere)
<jemc>
`Printf("Hello, World - %1 %2", [as Formattable: "123", 4])`
<aav>
do you know what representation is used in F64.from_bits() and U64.f64()? they produce different result and both results appeart to be something else then i expect
<aav>
?
<aav>
i guess U64.f64() is just conversion
<aav>
so it should not produce valid float from it's bit representation
<aav>
but i don't undertand why F64.from_bits() does not work. i checked it with the calculator and it's a valid IEEE754 floating point number
<jemc>
this was a subject of some recent discussion and changes, which may not be in the release you're using - let me check
<jemc>
the rebase method is preferred, but either is a way to resolve conflicts with the master branch
<TwoNotes>
The only difference
<jemc>
yep
<jemc>
the main thing to do is make sure you have the latest version of `master` from the upstream (the first two steps)
<jemc>
I suspect this is what tripped you up the first time
<TwoNotes>
I am doing #1. COnfirming last 2 steps are checkout httpng, then rebase httpng? That seems wrong
<TwoNotes>
oh wait, I missed that it wrapped on my display
<TwoNotes>
rebase httpng master
<TwoNotes>
rebase failed :(
<jemc>
might need to add the `-i` flag to rebase - I usually do
<jemc>
to give you the "interactive" mode where you can tweak individual commits
<TwoNotes>
Ok, I got the pick pick pick edit again
<jemc>
in the interactive mode, it will stop you after failing to resolve the conflicts, and it will be up to you to open the conflicted files in a text editor and resolve them yourself, then continue with the rebase
<jemc>
TwoNotes: feel free to use all `pick`s
<TwoNotes>
"could not apply 903e8ca... Rename IPAddress to NetAddress"
<jemc>
right, so now type `git status` to see which files conflict, and open those in an editor
<jemc>
in the editor, you're looking for lines with `>>>>>` chars which highlight the conflict
<jemc>
in the affected areas, it will show two versions of the file - you need to edit them so that only the correct version remains (and the `>>>>` chars are gone)
<jemc>
in other words, you just need to edit the file to look how it's actually supposed to look after merging those two changes