ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.2 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
asterite has quit [Ping timeout: 260 seconds]
asterite has joined #crystal-lang
p0p0pr37_ has joined #crystal-lang
p0p0pr37_ has joined #crystal-lang
p0p0pr37 has quit [Ping timeout: 240 seconds]
p0p0pr37_ is now known as p0p0pr37
raifai has joined #crystal-lang
<raifai> Hello Crystal people!
<raifai> I was wondering if somebody would be able to help me with some confusion I'm having with the Crystal compiler.
<raifai> Namely, it's believe that a struct's Float64 is actually a method
<raifai> I have a paste right about here: https://pastebin.com/TqtjgvrT
<FromGitter> <j8r> wow @asterite has made 3/4 of the commits this week https://github.com/crystal-lang/crystal/pulse
<FromGitter> <j8r> 19/25 commits
<raifai> When the compiler gets to line 95, it seems to think that "vx" is a function, when in fact it is simply a Float64 on the "Body" struct.
<raifai> I feel however like the compiler should be smart enough to tell that "vx" is a Float64 because I specifically told it so on line 10
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/issues/6074 might help when next version comes out
<FromGitter> <j8r> @raifai you comme from Go (or maybe C) right?
<raifai> C moreso than Go
<raifai> And JavaScript
<FromGitter> <j8r> Your structs aren't used properly, think they are like classes
<FromGitter> <j8r> but don't used them when you use huge amount of data
<FromGitter> <j8r> yes class =~ struct
<raifai> Yes. But in that Gitbook example they seem very very similar.
<raifai> Even going so far as to have a "new"/"initialize" method.
<FromGitter> <j8r> nope
<raifai> Which is a new one for me for structs.
<raifai> Do I have to add "property" to those Float64s?
<FromGitter> <j8r> You haven't to define types variables everywhere ;-)
<FromGitter> <j8r> just do in methods arguments
<FromGitter> <j8r> useful to define overloads
<raifai> It makes me feel cozy :P
<raifai> So what should I do?
<raifai> I'd prefer these things to be stack allocated.
<FromGitter> <j8r> yes of course you're right on this
<FromGitter> <j8r> maybe you should use NamedTuple instead of structs, because you only have initialize and no other methods
<raifai> I, on a lark, added "property x, y, z, vx, vy, vz, mass"
<raifai> To the top of Body
<raifai> Not knowing exactly what it does.
<raifai> And it fixed that problem.
<raifai> So...
<raifai> I have no idea why that worked.
<FromGitter> <girng> crystal is a statically typed language
<FromGitter> <j8r> getter you can also use
<FromGitter> <j8r> Because Numbers are "evaluated" at compile time
<FromGitter> <j8r> but when you set a getter, it definer a method like `def a : Int32`
<raifai> Yeah. I assumed they worked like the "auto properties" in C#
<FromGitter> <j8r> Yes, use getter insteand property if you don't have to change the value like `body.vx = 0.12`
<raifai> Alrighty. Well thanks for help me struggle through that
<FromGitter> <bew> You can even use the `record` macro to generate the structs and getters for each fields
<FromGitter> <j8r> if you know the variables before, and you haven't to change them of course :-)
<FromGitter> <j8r> minor style issue, you can remove empty parentheses`()` ;-)
<FromGitter> <j8r> `crystal tool format`
<FromGitter> <j8r> (not sure if its removes them :-/)
<FromGitter> <bew> raifai when you define a struct or class in Crystal, all fields are private, and you need a method to access from the outside
<FromGitter> <bew> `property` can generqte those methods for you
<raifai> Oh hey. I didn't actually know that.
<FromGitter> <bew> generate*
<raifai> I didn't realize they were private by default.
<FromGitter> <bew> But it also generates other methods that can be used to modify the fields from the outside
<FromGitter> <bew> So that's not good if you want those structs to be immutable
<raifai> They're not every mutated, no.
<FromGitter> <j8r> always use `getter`, and eventually when you want more extend to `property`. There is also `setter`
<FromGitter> <bew> To generate only the methods to get the fields values (not set them), use `getter` instead of `property`
<raifai> Thanks, you two!
<raifai> That's very helpful.
<FromGitter> <bew> You're welcome ;)
<FromGitter> <j8r> I'm happy I'm now able to compile statically linked appliactions for my ARM boards :-D
<FromGitter> <bew> You can even use the `record` macro as I said
<FromGitter> <bew> Doc: https://crystal-lang.org/api/0.24.2/toplevel.html#record%28name%2C%2Aproperties%29-macro
<FromGitter> <bew> See the examples of it
<FromGitter> <j8r> Crystal on Alpine Linux ARM64
<FromGitter> <bew> It'll generate the getters and initialize for you
<FromGitter> <bew> It's a handy macro to declare immutable structures
<raifai> I'm still not used to the idea of macros. I never did much get into C++
<FromGitter> <bew> That's nice @j8r!
<FromGitter> <bew> It's not the same macros, Crystal ones are much more powerful than C/C++
<FromGitter> <bew> Than the *macros in C/C++
<FromGitter> <j8r> haha yes totally @bew, e.g I've made a CLI https://github.com/j8r/clicr/blob/master/src/clicr.cr
<FromGitter> <j8r> with only one macro, I was totaly mad this day
<FromGitter> <j8r> a recursive macro that calls itself
<FromGitter> <bew> Fun :P
raifai has quit [Quit: Page closed]
<jeromegn> RX14: got some help from somebody who knows v8 a lot: "v8 doesn't have a way to signal that a longjmp has occurred.. you have to reach into internal v8 thread-local structures and trick it into thinking that each fiber is actually a thread. node-fibers does this by reseting v8's 3 TLS keys on every context switch. See the `v8::internal` stuff in this file:
<jeromegn> https://github.com/laverdet/node-fibers/blob/master/src/coroutine.cc . When looking at this source file you can assume `USE_V8_SYMBOLS` is true, and that `CORO_PTHREAD` and `CORO_FIBER` are false/undefined. It's a horrifying approach and definitely not for the faint of heart."
<jeromegn> "I'm not super familiar with goroutines but some initial research seems to indicate that they are built on top of threads, though with manual scheduling and careful pooling. In this case since each goroutine is actually backed by a real thread then all you need is proper Locker & Unlocker usage. On the other hand I can definitely verify that Crystal is using a setjmp/longjmp equivalent so in this case you would need to
<jeromegn> port my horrifying hack."
<jeromegn> maybe I can use channels to always run some functions from the same fiber
gizmore|2 has joined #crystal-lang
gizmore has quit [Ping timeout: 264 seconds]
hightower2 has quit [Ping timeout: 240 seconds]
hightower2 has joined #crystal-lang
<FromGitter> <girng> https://play.crystal-lang.org/#/r/41ga please take a look here at what i'm trying to accomplish
<FromGitter> <girng> im trying to implement a callback system for my .send, that only gets executed, when the server acknowledges (replies back) that the message was sent
<FromGitter> <girng> but only when i pass in a third parameter (which means i'm asking for the callback), so on user-request basis. not all the time
<FromGitter> <girng> You may be wondering why I'm trying to do this. It's because when I tell a player on the master server, that they need to go to a game instance server (across the world, maybe). I need to get a reply back from the game instance server acknowledge they received the *transfer key*, instead before telling them to transfer. ⏎ ⏎ Or, maybe, `.send` could just return "true/false" if the message was fully sent and
<FromGitter> ... RECEIVED. Then I could just do something like maybe: ⏎ ⏎ ``` if client.send("TESTMESSAGE"): ⏎ puts "message was sent fullly, and RECEIVED" ⏎ end``` ... [https://gitter.im/crystal-lang/crystal?at=5af25b3e18d6bdde3727f820]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/41gp ?
<FromGitter> <Blacksmoke16> or like, where the ballback doesn't do anything by default
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/41gw
<FromGitter> <Blacksmoke16> @girng ^
<FromGitter> <girng> @Blacksmoke16 very cool. the problem is however, after doing ` socket.write_bytes(new_message.bytesize) socket.send new_message`, i need to somehow yield, before continuing the execution. because i need to wait for a reply from server to acknowledge they got it. if that makes sense
<FromGitter> <girng> because after .send is called, it's not 100% certain the receiving end acknowledged they got the msg AFAIK, it just sends the data off
<FromGitter> <Blacksmoke16> yea i never used socket stuff, how would you *know* they got the message?
<FromGitter> <Blacksmoke16> or is that what the issue is here?
<FromGitter> <girng> because right after i do .send to the game instance server, i also do `.send` right after, to the client to tell them they need to connect to that game instance server. that means, if there was lag in the FIRST .send, it could possibly mean the user is connecting to the game instance before the master server message got there
<FromGitter> <girng> hard to explain, sorry i made a graph and bew said i need to just acknowledge that they received the message
<FromGitter> <fridgerator> @girng I don't know if that's a feature of socket communication ?
<FromGitter> <Blacksmoke16> yea sorry bit above my level
<FromGitter> <Blacksmoke16> never used sockets :/
<FromGitter> <girng> @Blacksmoke16 your example is kinda exactly what i asked though, i like it...iand will use it, once i can yield for a `received` message after .send. inline callback like that would be great..
<FromGitter> <fridgerator> isn't `HTTP::WebSocket#send` blocking anyways?
<FromGitter> <girng> quick q: when it's blocking, does that mean the execution doesn't continue until the message was fully sent, or does it just send it off, and continue execution?
<FromGitter> <fridgerator> what do you mean by fully sent ?
<FromGitter> <fridgerator> There is not response from the client that the message was received
<FromGitter> <fridgerator> It sends it, then execution continues after that
<FromGitter> <girng> ok yeah
<FromGitter> <girng> thank you just making sure
duane has joined #crystal-lang
kurko_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
duane has quit [Ping timeout: 246 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> @girng what lang are you using in Godot? C# or GDScript?
<FromGitter> <girng> gdscript
<FromGitter> <faustinoaq> (https://i.imgur.com/7VgS9Sx.gif "It's alive!!!") (https://i.imgur.com/7VgS9Sx.gif)
<FromGitter> <faustinoaq> It's alive!!! ✨
<FromGitter> <bararchy> I'm thinking of moving from SFML to Godot for my game
<FromGitter> <bararchy> @faustinoaq This is the rename functionality ?
<FromGitter> <faustinoaq> @bararchy yep
<FromGitter> <bararchy> cool!
<FromGitter> <bararchy> nice work
<FromGitter> <bararchy> @girng the good thing about SFML is that I can work with it using Crystal, the bad thing is it seems to lack support for some very basic stuff
<FromGitter> <girng> @bararchy your game is 2d,correct?
<FromGitter> <bararchy> yeha
<FromGitter> <bararchy> I really enjoy working with SFML, but then I got to a place where I need stuff like playing a video, or lightning effects etc.. and you there is no support at all for that
<FromGitter> <girng> @bararchy does SMFL have a particle system plugin or something perhaps?
<FromGitter> <girng> Godot recently overhauled their particle system to be GPU bound instead of CPU bound, performance has been awesome
__marty__ has joined #crystal-lang
<FromGitter> <bararchy> @girng It seems SFML is not really a game engine and more a big framework to do multimedia stuff, so anything else needs to be added.
<FromGitter> <bararchy> I think I'll move to Godot, even though it means using a wierd scripting languge
<FromGitter> <bararchy> lol
<FromGitter> <girng> @bararchy I think you'll like it. And worse case scenario you can always go back ahaha
<FromGitter> <bararchy> I might ping you regarding stuff :)
p0p0pr37_ has joined #crystal-lang
<FromGitter> <girng> @bararchy sure we can pm through gitter too. more than happy to help fellow crystal friend
p0p0pr37 has quit [Ping timeout: 256 seconds]
p0p0pr37_ is now known as p0p0pr37
snsei has quit [Remote host closed the connection]
<FromGitter> <bararchy> You know what @girng I think I'll try playing with SDL2 before going to Godot, it seems more comprehensive and support more stuff while not forcing me away from Crystal, because I only need 2d Godot might be an overkill
snsei has joined #crystal-lang
<FromGitter> <girng> Go for it =]
__marty__ has quit [Remote host closed the connection]
<txdv> no, crystal for it
<FromGitter> <bew> :P
pn-max has joined #crystal-lang
<pn-max> Hello
<pn-max> I'm curious, is there no number type for YAML values ?
<FromGitter> <girng> im just gonna use redis on the master server. nn to resolve tcp messages from game servers, they'll just all connect to the main redis and use redis.get/set. much easier
<FromGitter> <girng> gg girng, ty for playing
<pn-max> bc right now, if you have a yaml with for instance test: 2, you can't get the value from it using parse. At least I can't. the only way I've found to get the number is to modiy the yaml to be " test: "2" " and then parse, and then as_s.to_s.to_i which is... weird
<FromGitter> <girng> plus, i use this script i wrote to install redis on vps. very simple ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5af2858140f24c430463265e]
<FromGitter> <girng> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5af287746f9af87e04531a27]
<FromGitter> <girng> how can i catch this error?
<FromGitter> <girng> i've tried ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5af2879197f07c7e137c986b]
<FromGitter> <girng> inside pingponger def, i use `redis.pong` in a loop, every 1 second. i even have a `rescue` in my pingponger method
<FromGitter> <girng> the rescue is not catching either one
<FromGitter> <girng> ok nvm. looks like it does catch it. had the rescue outside of the loop `end`, but after the def's `end` :P FALSE ALERT! sorry
snsei has quit [Remote host closed the connection]
<oprypin> bararchy, SFML and SDL have very similar feature sets. they are not game engines and don't claim to be. they are more about bringing the gap between different underlying hardware and software
<FromGitter> <girng> `System.hostname` is returning `DESKTOP-FBJM7B1`
<FromGitter> <sam0x17> crystal's `Random` is automatically seeded yes?
<FromGitter> <girng> How can I get the local ip of the server?
<crystal-gh> [crystal] kostya opened pull request #6082: JSON::Serializable (master...json_attributes) https://git.io/vpiFZ
p0p0pr37_ has joined #crystal-lang
pn-max has quit [Read error: Connection reset by peer]
pn-max has joined #crystal-lang
alex`` has joined #crystal-lang
p0p0pr37 has quit [Read error: Connection reset by peer]
p0p0pr37_ is now known as p0p0pr37
<FromGitter> <girng> when i say server, i mean the server the crystal app is running on, not like a TCPServer connection
<FromGitter> <sam0x17> also is there a way to get the "epsilon" value for Float64 e.g. 0.00000000000000000000001 or whatever it is. I see constants for min and max infinity etc. Visual Basic / C# has this constant and calls it float.Epsilon
<FromGitter> <girng> ok n i think i found it, i do \` hostname -i \`
<FromGitter> <bararchy> oprypin TBH what I really need is the SDL_gfx module, currently SFML does not allow you to draw a shape using only points as in Polygons are not really supported
<FromGitter> <bararchy> also it seems Steam is shipping the SDL pre-built lib bundled with it's installation package which allows you to publish the game without needed the user to install SFML beforehand, also, another plus is that SDL is written in C, which means a bridge lib is not needed (Voidsfml
<FromGitter> <bararchy> but, plus for SFML is the awsome documentation, which is really lacking in SDL, also oprypin what you did for tutorial in crSFML made it super easy for begginers
<oprypin> bararchy, polygons are fully supported, what you said is false
<oprypin> shipping the games on Steam or otherwise is not a problem
<oprypin> the additional wrapper is not a problem either, you just put everything in one folder and call it a day
<oprypin> btw SDL_gfx is not even part of SDL
<FromGitter> <girng> spidy web
<FromGitter> <girng> dat game looks awesome
<FromGitter> <bararchy> oprypin my mistake, just figured out SFML has sf::ConvexShape
<FromGitter> <bararchy> which is what I need
<oprypin> and not even that, you can draw a polygon without creating an object
<oprypin> see "shapes" example
<oprypin> draws triangles but most of those approaches are expandable to polygons
<oprypin> well you'd need to use the "triangle fan" option, perhaps ConvexShape is the safer choice
<FromGitter> <niiru97_twitter> I have a sample code here, ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ how can i call `private def barbar` inside `self.init` method in `Bar` class? [https://gitter.im/crystal-lang/crystal?at=5af29c946d98e53e0462a0e0]
<oprypin> you can't call an instance method inside a class method because there is no instance to speak of
<oprypin> drop the self. maybe
<FromGitter> <bararchy> oprypin does crSFML has ConvexShape support?
<FromGitter> <bararchy> cool
<FromGitter> <niiru97_twitter> instance methods are in `self.method` name right?
<FromGitter> <hmans> @niiru97_twitter `self` in that case denotes the receiver of the method, and that receiver would be the class itself. Hence `self.foo` is a method `foo` on your class.
<FromGitter> <hmans> The code of such a method runs in the context of the class, not the instance, so if you call another method from within it, it would also need to be a class method.
<FromGitter> <niiru97_twitter> so you mean, if i'm going to call `self.foo` in another method it should be ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ right? [https://gitter.im/crystal-lang/crystal?at=5af29fde59a0578004b66959]
<FromGitter> <hmans> @niiru97_twitter Yes, that will work.
<FromGitter> <hmans> Methods without the `self.` prefix are instance methods, ie. they will live on instances created through `Foo.new`.
<FromGitter> <sam0x17> I just implemented bilinear interpolation image resizing if anyone needs it -- will probably eventually submit as a PR to stumpy_png
<oprypin> sam0x17, based on the project's architecture, maybe it would have to be a separate plugin for stumpycore
<FromGitter> <sam0x17> maybe, or its own library, I have a bunch of image functions implemented
<FromGitter> <bararchy> oprypin oh no, how can I do collusion detection for a ConvexShape? global_boundries gives me a rectangle while my shape can be any shape
rohitpaulk has quit [Ping timeout: 255 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
<oprypin> yes, now THAT is not implemented
rohitpaulk has quit [Ping timeout: 240 seconds]
<oprypin> this is basically a feature of physics engines
<FromGitter> <bararchy> םי
<FromGitter> <bararchy> oh
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> it seems wierd that I can't call `.contains?` on any Shape, as the shape should know all points it houses
<oprypin> it doesn't actually know that, drawing is the last step, done on gpu
<oprypin> if you mean the exact vertices, you could expand it to include Indexable
<oprypin> then it would have array-like methods
<FromGitter> <bararchy> so each shape becomes an array of points ?
<FromGitter> <bararchy> array of pixles
<FromGitter> <bararchy> btw, how does .global_bounds can know regarding `.contains?` ?
<FromGitter> <girng> raycast?
<FromGitter> <sam0x17> of relevance: https://en.wikipedia.org/wiki/Point_in_polygon
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <bararchy> hm...
rohitpaulk has quit [Ping timeout: 255 seconds]
rohitpaulk has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<FromGitter> <bararchy> I'm trying the idea suggested here: https://en.sfml-dev.org/forums/index.php?topic=18431.0 ⏎ mainly ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5af2ba77ff26986d0843ba89]
<FromGitter> <bararchy> So, I create a line between my player_position, and the starting_position which I know will never be inside a "collision area"
<FromGitter> <bararchy> then, I need to check if my line intersects exactly 1 edge of my poligon
<FromGitter> <bararchy> if it does it's inside the boundries and I get collision
<FromGitter> <bararchy> else it's outside of it
<FromGitter> <bararchy> oprypin does that makes sense to you? :)
<pn-max> hey..
<pn-max> does anyone know about the yaml numbers ? is there anyway to parse them without having to put them into braces, without having to create a mapping ?
<pn-max> into quotation marks, sorry, tired.
<FromGitter> <bew> Yes, don't use YAML.mapping :P
<FromGitter> <alfrednerstu> Hi, I'm getting some encoding errors when typing scandinavian characters (ÅÄÖ) in my ECR file, I'm using Kemal. Anyone have any idea how to fix? Code editor is set to UTF-8, long time since I had problems with encoding…
<FromGitter> <bararchy> @alfrednerstu what errors excatly?
<FromGitter> <alfrednerstu> Ö renders as ö, … renders as …, – renders as – for example
<FromGitter> <alfrednerstu> @bararchy
<pn-max> bew, what Im saying is
<pn-max> I havent found a way to use YAML.parse and actually get back numbers from a yaml file
<pn-max> if I dont input them like so : num: "1"
<pn-max> in the yaml itself.
<badeball> bararchy: odd number of intersections, not simply 1
<FromGitter> <bararchy> I think when talking ConvexShape you can't have 3
<badeball> ah, I see
<FromGitter> <bararchy> in Concave shape you can though :)
Cyrus has quit [Ping timeout: 264 seconds]
Cyrus has joined #crystal-lang
alex`` has quit [Ping timeout: 256 seconds]
pn-max has quit [Remote host closed the connection]
straight-shoota has joined #crystal-lang
<FromGitter> <gdotdesign> @alfrednerstu do you have `charset` meta tag set in the HTML to `utf-8`?
<FromGitter> <bararchy> badeball but I still can't figure how I test if the lines intersect :\
<FromGitter> <bararchy> this is my 2 lines
<FromGitter> <bararchy> can't figure what Math to use for check
<badeball> bararchy: that's also an interesting problem! check this out: https://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect
<badeball> it details out how to find the point of intersection, but having done that, you will obvously have figured out if they intersect
<badeball> since you're lines are finite (right?), I suppose you would have to check that the point of intersection lies within the bounderies
<badeball> take a look at this as well: http://cs.swan.ac.uk/~cssimon/line_intersection.html
<FromGitter> <bew> @bararchy `any part of this repo is spoiler land` :P
pn-max has joined #crystal-lang
<FromGitter> <bew> pn-max you can do `Int32.from_yaml "1"`
<pn-max> I love u
<FromGitter> <bew> you don't have to use `YAML.parse` (and you shouldn't)
<FromGitter> <bew> me too
<pn-max> why shouldn't I
<pn-max> the numbers I'm talking about are nested
<FromGitter> <bew> nested in what?
<FromGitter> <bew> wht does a typical document look like?
<pn-max> I'll send you, one sec.
<FromGitter> <bew> why not use a mapping here?
<pn-max> these are codes for keys in crSFML
<FromGitter> <bew> oh, a hash then ?
<FromGitter> <bew> huh no sorry
<FromGitter> <bew> the numbers are the codes for keys?
<pn-max> honestly : just bc I dunno how to do nested yaml mappings and I used parse for everything before (json).
kurko_ has joined #crystal-lang
<pn-max> right now it actually looks like that in my project but with every number with double quotations
<pn-max> Oh. it's actually really easy. just looked at the json docs. but I don't like to "solidify" it that way, still
<pn-max> and it seems to me
<pn-max> that its really weird there is no natural way to do it
<FromGitter> <bew> https://carc.in/#/r/41kh
<FromGitter> <bew> it fails
<FromGitter> <bew> but that has been fixed in master version of Crystl
<pn-max> !
<FromGitter> <bew> (we really need a new release, we'll maybe have one in the next weeks)
<pn-max> that's great
straight-shoota has quit [Ping timeout: 246 seconds]
<pn-max> Think I'll use a mapping in the meanwhile
straight-shoota has joined #crystal-lang
<FromGitter> <bararchy> @bew spoiler land indeed haha
<FromGitter> <bew> pn-max #5774
<DeBot> https://github.com/crystal-lang/crystal/pull/5774 (Fix YAML core schema parses integer 0)
<FromGitter> <bew> https://carc.in/#/r/41kk
<FromGitter> <bew> if I remove the 0 it works
<pn-max> sad that 0 is the a key
<pn-max> but awesome =)
<FromGitter> <bew> lol
<FromGitter> <bew> as a temporary solution you could parse the numbers as strings, and convert (`.to_i`) after parsing
<FromGitter> <ryankshah> If I have a method which takes a splat, i.e. `*example` which is a splat of `Proc`s - how can I use `@` with it to reference it throughout my class?
<FromGitter> <ryankshah> Or is this not possible?
<pn-max> bew that's what I'm doing now
<pn-max> but it doesnt work if the numbers are as if
<pn-max> you have to 'make' them strings by putting double quotes
<pn-max> else you get a typecast error
straight-shoota has quit [Ping timeout: 264 seconds]
straight-shoota has joined #crystal-lang
straight-shoota has quit [Read error: Connection reset by peer]
straight-shoota has joined #crystal-lang
<pn-max> yeah I'm using your solution instead
<pn-max> and just doing a trick so that 100 becomes the code for A
<pn-max> thanks =)
<pn-max> much nicer than a mapping imo
<pn-max> lol, no need
<pn-max> works with 00.
pn-max has quit [Remote host closed the connection]
<oprypin> pn-max, don't use key codes, use strings, it's much nicer!
zorp has joined #crystal-lang
<zorp> hi, I want to cross-compile crystal for openbsd, is there any documentation on how to do that?
<FromGitter> <j8r> @zorp create a port?
<zorp> there is no port for crystal and to compile it you have to use a crystal compiler, right? so I have to cross compile from a system with a working compiler
<FromGitter> <j8r> That's right
<FromGitter> <j8r> You'll need the same libraries versions though
<FromGitter> <ryankshah> Are there any hash functions i could implement which map a string to an integer?
<FromGitter> <bararchy> Zorp, isn't that a balabit product? XD
<zorp> hmm there is a binary release for openbsd 6.0. but only one and it's crystal 0.19.4 :/
<zorp> also current openbsd is 6.3
<zorp> wmoxam, maybe you know more about this? :)
<FromGitter> <j8r> that's better Zorp
<FromGitter> <j8r> you can compile incrementally, 0.19.4 => 0.20.0 => 0.21.0
<FromGitter> <j8r> etc
<zorp> I found a port :)
<zorp> thank you for your time tho, j8r!
straight-shoota has quit [Ping timeout: 260 seconds]
<jeromegn> anybody good with fibers? I figured out my issue and now everything works well. I had to expose the current fiber's stack_bottom address so I could set a sensible value with v8. basically, you can give v8 isolates (the vm) a stack limit address. I figured I'd give the stack a limit like the stack_bottom of the fiber.
<jeromegn> except I had to subtract about a 1MB from the stack bottom to make it work. else i was getting a v8::internal StackOverflow error :thinking:
<jeromegn> not looking for a specific answer, mostly some info about fibers.
txdv has quit [Ping timeout: 240 seconds]
<FromGitter> <bararchy> What does #6082 actually do?
shalmezad has joined #crystal-lang
<crystal-gh> [crystal] asterite opened pull request #6084: Formatter: correctly handle annotation path (master...bug/annotations_formatter) https://git.io/vpPli
<FromGitter> <bararchy> I hate math... ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5af2e9a018d6bdde3729b53a]
<FromGitter> <bararchy> I think I got it though
<FromGitter> <bararchy> lol
<FromGitter> <ryankshah> I'm trying to change the name of my module for my shard because I want it to be all lowercase but it starts with a capital
<FromGitter> <ryankshah> Are modules in Crystal meant to start with a cap?
<FromGitter> <bararchy> @ryankshah yeha
<FromGitter> <ryankshah> ahh
<FromGitter> <ryankshah> Cheers @bararchy
<FromGitter> <bararchy> np
txdv has joined #crystal-lang
<FromGitter> <bararchy> lol math power didnt help me
<FromGitter> <bararchy> :(
<FromGitter> <bararchy> It still shows collision wrong
<FromGitter> <bararchy> also it sometimes crash with "DivizionByZero"
hightower2 has quit [Ping timeout: 250 seconds]
duane has joined #crystal-lang
straight-shoota has joined #crystal-lang
_whitelogger has joined #crystal-lang
shalmezad has quit [Ping timeout: 256 seconds]
shalmezad has joined #crystal-lang
zorp has quit [Changing host]
zorp has joined #crystal-lang
<FromGitter> <bararchy> OMG I made the math work!
straight-shoota has quit [Ping timeout: 250 seconds]
straight-shoota has joined #crystal-lang
<FromGitter> <gdotdesign> 🎉
<FromGitter> <j8r> @barachy `t >=0 && t <= 1` == `0 <= t <= 1`
<FromGitter> <j8r> Looks like complicated calculations :o
straight-shoota has quit [Ping timeout: 250 seconds]
<FromGitter> <ParadoxZero> Hi, I am not sure if this is the right place to ask the question. Please forgive me if it is not. ⏎ ⏎ I just came across the project in GitHub, so I did not have any time to go through the docs. Just a quick question because I am extremely curious, how is static type checking implemented if the language uses dynamic type binding (was mentioned in the readme) ? In one of the examples in docs, the type
<FromGitter> ... of a variable was changed by the assignment operation.
<crystal-gh> [crystal] asterite pushed 2 new commits to master: https://git.io/vpPae
<crystal-gh> crystal/master 0e64622 Ary Borenszweig: Merge pull request #6084 from asterite/bug/annotations_formatter...
<crystal-gh> crystal/master 81845c5 Ary Borenszweig: Formatter: correctly handle annotation path
snsei has joined #crystal-lang
<FromGitter> <j8r> @ParadoxZero Everything is statically typed. The good part is the compiler, when the types aren't specified, it can guess what types we meant
<FromGitter> <ryankshah> How could I go about porting cpp code to crystal?
<FromGitter> <j8r> By doing code, lol. You can also create bindings if you don't want to port
<FromGitter> <ryankshah> I mean binding x_x I used the wrong term hehe
straight-shoota has joined #crystal-lang
<FromGitter> <ryankshah> I've started writing a port but it may end up being easier to just write a binding
<FromGitter> <j8r> Not an expert on bindings, but it seems to work also OK for C derivatives like C++, Objective-C
<FromGitter> <asterite> Nope, doesn't work for C++. You have to write a wrapper in C
<oprypin> j8r, literally only C
<FromGitter> <ryankshah> Ugh ew
<FromGitter> <ryankshah> Actually wait
<FromGitter> <j8r> Really?
<FromGitter> <ryankshah> There's a C wrapper for what I'm trying to bind #winning
<oprypin> ryankshah, check out bindgen for c++
<FromGitter> <j8r> Too bad :(
<travis-ci> crystal-lang/crystal#0e64622 (master - Merge pull request #6084 from asterite/bug/annotations_formatter): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/376841375
<DeBot> https://github.com/crystal-lang/crystal/pull/6084 (Formatter: correctly handle annotation path)
<FromGitter> <j8r> I thought Cocoa was in Obj-C
<oprypin> ParadoxZero, instead of "type of the variable was changed" you can think of it as forgetting the old variable and creating a new one with the same name
<oprypin> the type system is amazing, you can just read the docs, they're concise
<oprypin> types of variables (e.g. instance variables) definitely dont change
<jeromegn> @j8r I think you can do C++ by using an `extern "C"` block. At least that's what I'm doing. However I can't tell if it's going to work well on other people's machines. I'm going to setup CI soon to test on various arch too.
ua has quit [Quit: Leaving]
ua has joined #crystal-lang
straight-shoota has quit [Ping timeout: 250 seconds]
straight-shoota has joined #crystal-lang
greengriminal has joined #crystal-lang
greengriminal has quit [Quit: Leaving]
greengriminal has joined #crystal-lang
<FromGitter> <bararchy> @ryankshah what are you binding?
rohitpaulk has quit [Ping timeout: 250 seconds]
kurko_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
straight-shoota has quit [Ping timeout: 250 seconds]
rohitpaulk has joined #crystal-lang
straight-shoota has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 250 seconds]
straight-shoota has quit [Ping timeout: 250 seconds]
_whitelogger has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter> <bararchy> oprypin SFML 2.5.0 is out in Arch
<FromGitter> <bararchy> :)
greengriminal has joined #crystal-lang
greengriminal has quit [Quit: Leaving]
ssvb has quit [Ping timeout: 240 seconds]
chamar has joined #crystal-lang
<oprypin> wuuut
<oprypin> release notes pls?
kurko_ has joined #crystal-lang
<oprypin> generates this line ` VOIDCSFML_API sfml_void_sANxAL(** context_destroy_callback, void* p1, typedef* result);` lol
_whitelogger has joined #crystal-lang
<FromGitter> <bararchy> oprypin oh no
<FromGitter> <bararchy> my game broke due to VOIDCSFML
<FromGitter> <bararchy> :(
<oprypin> ?
<FromGitter> <bararchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5af346f646c3af24b4b0d367]
<oprypin> well yeah that's what i mean
<oprypin> it's the generator that's broken
<oprypin> i think i'll fix it today
<FromGitter> <bararchy> oprypin cool :) I'm stuck with trying to test
<oprypin> you're not really stuck, you can always use sfml 2.4
<FromGitter> <bararchy> blasphemy!
<FromGitter> <bararchy> lol
<oprypin> dang, crystal is broken with this
<oprypin> https://github.com/SFML/SFML/blob/master/include/SFML/Window/Keyboard.hpp#L158 and .parse says duplicate `case "backspace"; case "backspace"`
zorp has quit [Ping timeout: 250 seconds]
<FromGitter> <bararchy> :\
zorp has joined #crystal-lang
<oprypin> so should i keep only the deprecated name, or only the backwards-incompatible name, or change Crystal
<jeromegn> Is it safe to use a LibC::Char* directly from C? or should I malloc it first?
<jeromegn> and copy
<oprypin> jeromegn, whether it is safe is basically part of the lib's API
<oprypin> it should say whether it will keep that alive or destroy ASAP
<oprypin> besides, normally you might do String.new which copies anyway
kurko__ has joined #crystal-lang
<jeromegn> ah cool, yea that's what I was wondering about.
<jeromegn> I have a bunch of places where it transforms some value into a std::string and the malloc + memcpy, but I bet this is stuff go needed
kurko_ has quit [Ping timeout: 256 seconds]
<zorp> wmoxam: just a heads up, your openbsd port will not build without bash installed
alex`` has joined #crystal-lang
<FromGitter> <bew> oprypin, I'd say keep the backwards-incompatible name
<oprypin> bew, i'ma try to monkeypatch enum.parse
davic has quit [Ping timeout: 265 seconds]
<oprypin> actually it's not even monkeypatch, just override it for my enum
<oprypin> oh you cant reopen an enum?
<oprypin> you can
<oprypin> ayy it works
zorp has quit [Read error: Connection reset by peer]
davic has joined #crystal-lang
gizmore has joined #crystal-lang
gizmore|2 has quit [Ping timeout: 260 seconds]
<FromGitter> <bew> what did you do?
<FromGitter> <bew> nice:
<FromGitter> <bew> *!
<FromGitter> <j8r> what the difference between `%w()` and `%w[]`?
<oprypin> j8r, no difference, like %( and %[
<oprypin> it's just weird to use %w( for an array when %w[ works :p
<oprypin> (note: crystal formatter enforces `(` which is lame)
<FromGitter> <j8r> so you're code isn't really formatted?
<FromGitter> <j8r> :-)
<oprypin> formatted how i want it
<oprypin> no but have you looked at the file? it's scary
<FromGitter> <j8r> Haha, I agree with your syntax choice on this point
<FromGitter> <j8r> omg
<FromGitter> <j8r> I just see this regexes in the case block
<FromGitter> <j8r> Why have you not splitted each/some classes in files?
<oprypin> at this point this code is only meant for me and i like it in one file so whatever
kurko__ has left #crystal-lang ["Textual IRC Client: www.textualapp.com"]
shalmezad has quit [Quit: Leaving]
gizmore|2 has joined #crystal-lang
gizmore has quit [Ping timeout: 264 seconds]
pfl[m] has left #crystal-lang ["User left"]
kosmonaut has quit [Remote host closed the connection]
kosmonaut has joined #crystal-lang
kosmonaut has quit [Client Quit]
kosmonaut has joined #crystal-lang
<jeromegn> alright, so my v8 bindings work pretty well. since v8 doesn't like fibers much, I have to set a different stack limit on every context switch.
<jeromegn> right now, I'm exposing the @stack_top from the current Fiber to C and adding some padding to it. Hoping it won't overlap
<jeromegn> Unfortunately that bombs rapidly with a StackOverflow error from v8. What works though is subtracting the same padding from stack_top.
<jeromegn> but then I'm afraid the stacks will overflow from somewhere else
kosmonaut has quit [Client Quit]
<jeromegn> any tips would be appreciated :)
<jeromegn> oh, using @stack instead of @stack_top works.
kosmonaut has joined #crystal-lang
kosmonaut has quit [Quit: The Lounge - https://thelounge.chat]
kosmonaut has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.1]
gizmore has joined #crystal-lang
kosmonaut has quit [Client Quit]
kosmonaut has joined #crystal-lang
gizmore|2 has quit [Ping timeout: 255 seconds]
kosmonaut has quit [Client Quit]
kosmonaut has joined #crystal-lang
sz0 has joined #crystal-lang
kosmonaut has quit [Quit: The Lounge - https://thelounge.chat]
kosmonaut has joined #crystal-lang
faustinoaq has quit [Ping timeout: 255 seconds]
kosmonaut has quit [Client Quit]
kosmonaut has joined #crystal-lang
kosmonaut has quit [Client Quit]
kosmonaut has joined #crystal-lang
kosmonaut has quit [Client Quit]
kosmonaut has joined #crystal-lang
kosmonaut has quit [Quit: The Lounge - https://thelounge.chat]
kosmonaut has joined #crystal-lang
kosmonaut has quit [Client Quit]
kosmonaut has joined #crystal-lang
duane has quit [Ping timeout: 256 seconds]
kosmonaut has quit [Remote host closed the connection]
kosmonaut has joined #crystal-lang
kosmonaut has quit [Quit: The Lounge - https://thelounge.chat]
kosmonaut has joined #crystal-lang
kosmonaut has quit [Quit: The Lounge - https://thelounge.chat]
kosmonaut has joined #crystal-lang