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
unbalancedparen has quit [Ping timeout: 252 seconds]
SirWillem has quit [Remote host closed the connection]
jonrh has quit [Ping timeout: 276 seconds]
jonrh has joined #ponylang
unbalancedparen has joined #ponylang
copy` has quit [Quit: Connection closed for inactivity]
jemc has quit [Ping timeout: 260 seconds]
amclain has quit [Quit: Leaving]
jemc has joined #ponylang
jemc has quit [Ping timeout: 260 seconds]
mcguire has quit [Ping timeout: 252 seconds]
hakvroot_ has joined #ponylang
akant has joined #ponylang
<akant> hey gang, does anyone know whether you can access the type information for a particular variable without using match?
<akant> I was wondering if it would be possible to use the type information in a conditional (e.g., "if foo.type() == String then ...")
hakvroot has quit [Ping timeout: 246 seconds]
<akant> s/String/"String"
mcguire has joined #ponylang
<doublec> akant: if foo is String then
<akant> ugh
<akant> i knew that was going to be a facepalmer. Thanks =)
<doublec> no
<doublec> oops, np
<doublec> :)
trapped has joined #ponylang
unbalancedparen has quit [Quit: WeeChat 1.5]
<akant> doublec: I'm having trouble getting that to work on anything other than "None"
<akant> I remember seeing something about "is None" in the tutorial or somewhere else, but I can't seem to find it now
<akant> e.g. the following statement will never execute the '...' block, var foo : String = "foo"; if foo is String then ...
<jonas-l> `is` compares by identity and not by type
<jonas-l> it all depends on your needs, akant
<jonas-l> but one way to test it is
<jonas-l> try s as String; doSomething() end
<jonas-l> `as` causes error if type does not match
<jonas-l> I guess you would like to use the String value. In that case `try` makes more sense than in my first example
<jonas-l> try methodAcceptingString(s as String) end
<jonas-l> or
<jonas-l> try (s as String).substring(...) end
<akant> jonas-l: thanks. I was thinking more along the lines of how in http://tutorial.ponylang.org/pattern-matching/match.html it says "In many languages using runtime type information is very expensive and so it is generally avoided whenever possible.
<akant> In Pony it's cheap."
<akant> it clearly is talking about how it is used in match statements by type, but it's not clear whether this information is available outside of match statements
tankfeeder has joined #ponylang
<tankfeeder> morning
<akant> morning!
trapped has quit [Read error: Connection reset by peer]
<jonas-l> akant, I don't think type information is available right now. If you are looking for reflection, then it's definitely not available.
<jonas-l> there's a very old ticket still open: https://github.com/ponylang/ponyc/issues/87
<jonas-l> morning, tankfeeder
<akant> jonas-l: interesting. Yeah I'm talking about reflection, but only a subset of the features of it. If we can "match" by type, then I'd imagine we should be able to use type information elsewhere
<akant> Obviously I could do a match by type and "else", but I was wondering if there was some other way to expose the functionality. Maybe in later versions =)
lispmeister has joined #ponylang
jeremyheiler_ has joined #ponylang
strmpnk_ has joined #ponylang
SeanTAllen_ has joined #ponylang
bbhoss_ has joined #ponylang
hakvroot has joined #ponylang
adamkittelson_ has joined #ponylang
kushalp_ has joined #ponylang
Candle_ has joined #ponylang
omarkj has quit [Ping timeout: 250 seconds]
jeremyheiler has quit [Ping timeout: 250 seconds]
strmpnk has quit [Ping timeout: 250 seconds]
kushalp has quit [Ping timeout: 250 seconds]
mcguire has quit [Ping timeout: 250 seconds]
Candle has quit [Ping timeout: 250 seconds]
SeanTAllen has quit [Ping timeout: 250 seconds]
bodie_ has quit [Ping timeout: 250 seconds]
jtfmumm- has quit [Ping timeout: 250 seconds]
bbhoss has quit [Ping timeout: 250 seconds]
cquinn has quit [Ping timeout: 250 seconds]
mankyKitty has quit [Ping timeout: 250 seconds]
adamkittelson has quit [Ping timeout: 250 seconds]
hakvroot_ has quit [Ping timeout: 250 seconds]
lisael has quit [Ping timeout: 250 seconds]
lisael has joined #ponylang
bodie__ has joined #ponylang
jeremyheiler_ is now known as jeremyheiler
bodie__ is now known as bodie_
jonrh has quit [Ping timeout: 308 seconds]
SeanTAllen_ is now known as SeanTAllen
mcguire has joined #ponylang
kushalp_ is now known as kushalp
adamkittelson_ is now known as adamkittelson
strmpnk_ is now known as strmpnk
gornikm has quit [Ping timeout: 276 seconds]
mankyKitty has joined #ponylang
bbhoss_ is now known as bbhoss
omarkj has joined #ponylang
srenatus has joined #ponylang
jonrh has joined #ponylang
gornikm has joined #ponylang
cquinn has joined #ponylang
Praetonus has joined #ponylang
jtfmumm has quit [Ping timeout: 260 seconds]
jtfmumm has joined #ponylang
<sylvanc> akant, doublec: `if foo is String` is wrong! sorry :)
<sylvanc> that's a constructor
<sylvanc> you are creating a new String, and asking if foo is the new String
<sylvanc> which will always be false
<sylvanc> as jonas-l says
<sylvanc> oh wait, everything i was gonna say, jonas-l already covered :)
<doublec> sylvanc: that makes sense, thanks
copy` has joined #ponylang
<SeanTAllen> I got the if foo is String thing wrong as well initially
<jonas-l> me too
<jonas-l> I guess this is due to similarities to other languages
trapped has joined #ponylang
trapped has quit [Read error: Connection reset by peer]
trapped has joined #ponylang
_andre has joined #ponylang
tm-exa has joined #ponylang
<shepheb> > type aliases cannot be recursive
<shepheb> why not?
<shepheb> it seems perfectly sound to me.
<shepheb> type Foo is (String | I32 | Array[Foo]) is recursive, but any finite type is either a Foo ro not.
<jonas-l> I think this question was answered in old mailing list
<jonas-l> I'm not sure it's still available
<shepheb> I'll stalk it on Google then
<jonas-l> someone was writing Json Parser
<jonas-l> and faced the same problem
Praetonus has quit [Ping timeout: 260 seconds]
TwoNotes has joined #ponylang
jemc has joined #ponylang
puzza007 has quit [Ping timeout: 260 seconds]
puzza007 has joined #ponylang
Praetonus has joined #ponylang
Praetonus has quit [Client Quit]
<sylvanc> it's not fundamentally problematic for type aliases to be recursive
<sylvanc> but it will take some serious compiler work to make it possible
<shepheb> that's exactly what I was looking at, a JSON parser that does way less copying and nesting
<shepheb> sylvanc: that's about what I expected :/
<sylvanc> basically, the compiler currently expands type aliases early on
<sylvanc> which is Bad (tm)
<shepheb> I've got some ~80M JSON files here and parsing them is using all my memory. which seems surprisingly heavy.
<sylvanc> instead, type aliases should be handled directly everywhere in the code
<sylvanc> the current json package needs to be completely replaced, yeah
<shepheb> it didn't used to, but I'm also not seeing changes to the code.
<shepheb> I guess I can use it's types but be a lot gentler about copying
<sylvanc> hmm, if it didn't used to, there's no change that _should_ be making it take more memory
<sylvanc> so it's possible there's a bug
<shepheb> let me poke at it
<sylvanc> ok thanks
<shepheb> I've also switched from RasPi 2 to an x86_64 VM, which doubled the width of a pointer, but still
<shepheb> certainly no interesting changes to the JSON package itself.
<TwoNotes> My x86_64 images are 15% bigger than my armv7 images. That can't be all due to bigger pointers can it?
<shepheb> sylvanc: is there a better middle ground between the fully recursive type alias I want, and the wrapping structures in the current JSON package?
<shepheb> I'm thinking of eg. Haskell's newtypes
<shepheb> that create real, disjoint types that are essentially compiler ghosts, the runtime representation is identical to the original type.
<shepheb> I guess I could also completely invert the API and do an event-driven thing like some XML parsers.
<shepheb> that would probably marry it to my exact types, I don't know.
<shepheb> well, I could use a Notifier style interface or something. I'll think about it.
Applejack_ has joined #ponylang
<Applejack_> hi, following on my previous question on Gsl (which integration with Pony I made great progress on thanks to the many suggestions I had received here), I would like to know how to access C global variables through the FFI
<Applejack_> Gsl relies on environment variables, through which it selects the right global variable, cf. http://www.gnu.org/software/gsl/manual/gsl-ref.html#Random-number-environment-variables
<Applejack_> So I understood how to use Pony FFI to set the seed of a particular random generator thanks to a function http://www.gnu.org/software/gsl/manual/gsl-ref.html#index-gsl_005frng_005fset
<jemc> shepheb: regarding your memory issue - I've seen something similar with an initial naive implementation of my pony-ast parser
<jemc> shepheb: I solved it there by avoiding copying when I sliced strings
<jemc> shepheb: we discussed a few weeks ago the need to provide copy-free slice methods for String and Array[U8], to return a new object containing the same Pointer[U8] but a different offset and size
<jemc> right now I am doing my slicing in pony-ast using a wrapper class, but we need to make these methods available on the String and Array classes directly
<TwoNotes> That would help all sorts of parsing algorithms
<jemc> basically, before I made the lazy-copy optimization to my pony-ast parser, parsing an AST for a reasonably sized pony program was exhausting memory on my computer
<jemc> with lazy-copy, it's much more reasonable and fast
<Applejack_> But when I use the function to select the random generator I want http://www.gnu.org/software/gsl/manual/gsl-ref.html#Random-number-generator-initialization I don't know how to pass it the global variable that corresponds to the said random generator, say "gsl_rng_taus"
<jemc> Applejack_: I'll take a look at your links, but when it comes to accessing global C variables from FFI, the answer in all languages' FFIs that I know of is that you can't do this, and you need to find another way
<Applejack_> jemc: I know Haskell has it, although never used it
<Applejack_> jemc: So another way would be to manipulate environment variables but I haven't looked that up in Pony: is it dead simple or should I again use the FFI to do that?
<jemc> Applejack_: setting environment vars is simple to do when you're running a subprocess with the `process` package, but there's no Pony API to set them within the running program, only to get the env vars which the program was invoked with
<shepheb> this JSON parsing stuff is crying out for a bit of reflection
<shepheb> I've got these objects with a bunch of fields named identically to the JSON fields, etc.
<jemc> Applejack_: looks like `gsl_rng_types_setup` could be the solution to your problems
<jemc> lets you iterate over the available rng types
<Applejack_> @jemc: looks right on spot, thanks
<jemc> good luck!
<jemc> (also, didn't know about Haskell FFI letting you access C globals - that's new to me :)
SilverKey has joined #ponylang
SilverKey has quit [Read error: Connection reset by peer]
SirWillem has joined #ponylang
SilverKey has joined #ponylang
SilverKey has quit [Max SendQ exceeded]
SilverKey has joined #ponylang
SilverKey has quit [Max SendQ exceeded]
SilverKey has joined #ponylang
SilverKey has quit [Client Quit]
tankfeeder has quit [Quit: Leaving]
<TwoNotes> It seems to me that a JsonObject is just a Map[String,Any] with a bunch of additional methods.
graaff has joined #ponylang
Applejack_ has quit [Ping timeout: 250 seconds]
<jemc> TwoNotes: well, not `Any` - you would want it to be restricted to valid json values
<shepheb> I'm making progress on a token-stream style JSON parser
<shepheb> which is definitely the most efficient way, but it's a definite speed vs. efficiency trade-off
<shepheb> it could of course be used as the basis for a tree-building JSON parser later.
<jemc> shepheb: yeah, I was going to mention tokenizing json parsers for memory efficiency, like frozen: https://github.com/cesanta/frozen
<jemc> I've worked with projects before that used that library on constrained devices
<jemc> when you know what indexes/keys you're looking for, it's definitely more efficient than eagerly loading everything into memory
<jemc> however, as I mentioned before, having proper zero-copy String slicing would go a long way toward improving memory efficiency of the eager scheme
amclain has joined #ponylang
unbalancedparen has joined #ponylang
copy` has quit [Quit: Connection closed for inactivity]
<shepheb> yes, string copying is easily the biggest performance hole here
<shepheb> there is a curious catch, though: JSON strings can contain escape sequences, so when the user demands the string we need to copy it anyway
<shepheb> I'm already doing that lazily, since he may just be skipping over some large blob
<shepheb> but it is definitely unfortunate
<jemc> right, escape sequences are a problem for zero-copy - I'm going to run into that with pony-ast as well after I fix this issue: https://github.com/ponylang/ponyc/issues/724
SirWillem has quit [Ping timeout: 252 seconds]
<shepheb> they're also a problem for getting the refcaps right
<shepheb> things like String.append are trying to turn my String iso into a String ref
tm-exa has quit [Quit: Computer has gone to sleep]
<jemc> if you are trying to chain from the return value, yes that's a problem
<jemc> should be able to append to an iso if you don't use the return value and the argument is sendable, though
<TwoNotes> In the olden days we never copied strings except when adding names to the symbol table, etc. It was all done by moving a pointer through a big buffer and making decisions based on what was found there.
<TwoNotes> Indeed, I just wrote my own XML parser that works like that, after giving up getting Regex to work
<TwoNotes> Those escape sequences do mess things up. Erlang's External Binary Format has some advantages in that everything has a count prefix.
<jemc> MessagePack does too (a popular alternative with roughly the same semantics as JSON, but without human-readability)
lispmeister has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tankfeeder has joined #ponylang
<TwoNotes> How about a human-readable prefixed count? 5Hello
<jemc> TwoNotes: it gets a bit more complex than that - how do you know the number of bytes in your prefix? For example, if the parser sees 11HelloWorld! how does it know to parse the string `HelloWorld!` instead of the string `1` (where `1` is the prefix and the following 1 forms the entire 1-byte string)
<jemc> you can do things to guard against this, sure, but you still have the problem that such schemes are not very human-*writable* - who wants to count bytes when they're writing a config file?
<shepheb> I'm really struggling with refcaps on the JsonParser.
<shepheb> it's not itself an iso, and it can't be val because it contains internal state.
<shepheb> but I want to parse things into a val
<shepheb> but then this is a generic function - any [A: FromJson val] will do
<jemc> shepheb: you might find some inspiration in my pony-ast package: https://github.com/jemc/pony-ast/blob/master/ast/ast_parse.pony
<shepheb> generics are a fount of suffering
graaff has quit [Quit: Leaving]
<shepheb> I've only got three types here, I could specialize this function by hand, but that really bites
<jemc> my approach in pony-ast is to make the parser a class `ref`, it takes a `ReadSeq[U8] val` as input, and outputs an `AST val`
<jemc> the internal state is only valid during a single parse run, and is cleared each time to make way for the new run
<shepheb> that's roughly what the original JSON library does - it returns a val tree
<shepheb> my JsonParser might be called a JsonTokenStream or similar
<shepheb> you call next_token on it, and fetch values when appropriate with get_int(), get_bool(), etc.
<shepheb> so even while parsing a single JSON blob, it's got moving parts internally.
<jemc> shepheb: no, the current JsonDoc doesn't return a val tree - it holds a ref field with the mutable tree
<jemc> which is part of the problem, IMO
<shepheb> quite possibly
<shepheb> for my fairly simple case this streaming API works fine
<shepheb> but I can't satisfy the type system her
<shepheb> e
<jemc> when I said "part of the problem" I was talking about the current API, not your API
<jemc> it was a continuation of my earlier statement, not a response to yours, FYI
<jemc> if you post a gist with what you're doing I can try to help you with the ref caps
<shepheb> yeah, give me a minute.
<shepheb> main part that's intersting is the loader.pony line 25
<shepheb> ah, that wasn't quite the closest version, probably remove the recover around the JsonParser(arr) on line 12
<shepheb> oh, it's also worth mentioning that I used to parse the JSON as a new val from_json
<shepheb> ah, hm.
<shepheb> that didn't work originally because it didn't necessarily write any of the fields
<shepheb> so I gave them all defaults and made from_json a method
<shepheb> but I could make it a new val constructor again, and keep the field defaults.
<shepheb> nope, that doesn't work either - the parameter must be sendable.
<jemc> might be possible to move the whole loader shebang into a recover block
<jemc> that is, make _deserialize_array return an Array ref instead, but call it from inside the other recover block
<jemc> as long as the non-sendable JsonParser is created inside the recover block, and the only things passed into the recover block are sendable (either the FilePath or the Array[U8] val), it should work
SirWillem has joined #ponylang
felixonmars has quit [Ping timeout: 260 seconds]
<jemc> you'll need to remove your val constraint on A though
<jemc> but if I'm getting the caps right in my head, an `Array[A] val` will have elements of type val->A, so you should be okay
<tankfeeder> giveup, cant build pony on centos7
<tankfeeder> llvm-3.6.2
felixonmars has joined #ponylang
<jemc> shepheb: by the way, I like your approach - with a little polishing it should make a nice little API for certain JSON needs not covered by the typical eager approach
<shepheb> I've got to run. I'll see what I can do.
<shepheb> jemc: it can also be the basis of a hopefully faster tree-building parser.
<shepheb> and yeah, I like this too
<shepheb> I don't mind suffering a bit for the speed in my case, I've got three 80MB JSON files to parse D:
copy` has joined #ponylang
<jemc> tankfeeder: I haven't seen anything like that before, and I'm using 3.6.2 on Fedora
<tankfeeder> centos 7 with all updated.
<tankfeeder> its ok.
<jemc> tankfeeder: do you possibly have multiple LLVM versions installed - it's possible that something is wrong and a mixture of them are being used
<tankfeeder> epel have only 3.4.2, which doesnt work
<tankfeeder> so i manually copy file from binary for fedora
<tankfeeder> from binary release.
<jemc> do you have 3.4.2 installed, though?
<tankfeeder> no, i removed by yum
<tankfeeder> before manual copy
Matthias247 has joined #ponylang
lispmeister has joined #ponylang
Matthias247 has quit [Read error: Connection reset by peer]
Matthias247 has joined #ponylang
tankfeeder has quit [Quit: Leaving]
SirWillem has quit [Ping timeout: 276 seconds]
<akant> when did the logo change?
<akant> (I like it though)
<akant> ah, looks like may 13
<SeanTAllen> there's an email to the mailing list about it akant. there's a logo coming soon, that's Main the mascot.
SirWillem has joined #ponylang
<akant> Oh, I should make sure I'm on that mailing list then =)
<akant> His name is Main?
Applejack_ has joined #ponylang
<TwoNotes> I thought he was the mascot, not the logo. hmm
<TwoNotes> Need something 16x16 or 32x32 for use on desktop icons
<TwoNotes> Like Java has its "cup of coffee" symbol
<SeanTAllen> akant: yup. Main.
<SeanTAllen> TwoNotes: he is the mascot. Jason has a couple logos that he sent to Sylvan and I today that will be hitting the mailing list soon.
<darach> Has Main got a License yet? I've generated icons from Main I can put in a git repo
srenatus has quit [Quit: Connection closed for inactivity]
<SeanTAllen> Yes
lispmeister has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
_whitelogger has joined #ponylang
trapped has quit [Read error: Connection reset by peer]
<shepheb> huh. I'm getting "undefined reference to setupterm" and a few other functions apparently from libtinfo. I have libtinfo-dev installed.
<shepheb> Ubuntu 14.04 with built-from-source clang and LLVM
<shepheb> (3.7.1)
<TwoNotes> darach, when you reduce the full image down so small, you lose an awful lot. How about just taking the head, like this: http://imgur.com/viDaO8i
<jemc> darach: yeah, I had the same thought as TwoNotes regarding just the head on small images
<TwoNotes> I threw in some coloring on the body so that your eye does not have to see just the very thin lines to make out the shape. That is just something I did quickly, it could be done better with more time.
<TwoNotes> The trick was in capturing the whimsy of the face in such little informtion. That one is 32x32
tm-exa has joined #ponylang
Applejack_ has quit [Ping timeout: 250 seconds]
<darach> TwoNotes. I'll play with that tomorrow and see what I come up with, Or fork ;)
TwoNotes has quit [Quit: Leaving.]
<SeanTAllen> I have the SVGs. If people give me sizes, I can size w/o loss in quality.
<jemc> I think TwoNotes' other point about white-on-white is a good one as well, in terms of making the mascot pop better on a white background - I don't know what the original artist thinks, but giving the fur coat a slight color might be nice
tm-exa has quit [Quit: Computer has gone to sleep]
<SeanTAllen> darach: i sent you the SVG.
<SeanTAllen> and now i make dinner
<darach> Ta! 40 winks for me, fly to Malaga, finish slides, continue the battle with LLVM on mips!
<jemc> LLVM vs the battle wombat
hibnico has joined #ponylang
hibnico has quit [Client Quit]
Matthias247 has quit [Read error: Connection reset by peer]
aturley has joined #ponylang
unbalancedparen has quit [Ping timeout: 260 seconds]
aturley has quit [Ping timeout: 244 seconds]