<FromGitter>
<girng> looks like damn sorcery , i like it !
<FromGitter>
<bew> Just a macro expression
<FromGitter>
<girng> wait, your using a macro?
<FromGitter>
<girng> where is it defined or can it be done inline?
<FromGitter>
<bew> Yes it's like a single line macro
<FromGitter>
<girng> O_O
<FromGitter>
<girng> @bew ohh i get it.. so the macro in {{}} literally "copies the code" doesn't pass by a reference (if used in a parameter)
<FromGitter>
<girng> that's why it works for the mapping method
<FromGitter>
<girng> if i gott hat right
<FromGitter>
<bew> Yes you got it :)
<FromGitter>
<girng> that's pretty cool / sneaky. i assume macros are pretty powerful??
<FromGitter>
<girng> never heard of this feature in javascript or php
<RX14>
There's a section in the docks on macros
<FromGitter>
<girng> wow i really like the * with interpolating
<FromGitter>
<girng> that's like the javascript spread operator??
<RX14>
Yeah
<FromGitter>
<girng> RX14 = :D
<FromGitter>
<girng> if you go this video here (https://youtu.be/xbdVs4FhZac?t=1542), juan the man stated my exact reason why i like crystal
<FromGitter>
<girng> "so you don't have to deal with callbacks in nodejs, you just have to write linear code" I LIKE THAT, a lot
DTZUZU has quit [Quit: WeeChat 1.9]
<FromGitter>
<girng> wow, a person at 31:04 cut off juan, not nice!
DTZUZU has joined #crystal-lang
CNSOK1Korigan has joined #crystal-lang
CNSOK1Korigan has quit [Remote host closed the connection]
sz0 has quit [Quit: Connection closed for inactivity]
qard has joined #crystal-lang
themill890 has joined #crystal-lang
themill890 has quit [Remote host closed the connection]
<faustinoaq>
Hey community, I just discovered something amazing, the UI (user interface) of [this](https://nikolamotor.com/nzt) VEHICLE is... written in Crystal!!!
<faustinoaq>
^^ A pretty nice use-case for crystal (embedded systems) +100
<FromGitter>
<bew> that's pretty cool!! where did you did that it's in Crystal?
<FromGitter>
<girng> how did they get crystal on the web? webassembly?
<FromGitter>
<bew> where do you see "crystal on the web" @girng ?
<faustinoaq>
@bew That vehicle is released by the company Nikola Motor, I don't work there but @elorest :)
<FromGitter>
<girng> "the ui of this vehicle"
<FromGitter>
<elorest> Can confirm.
<FromGitter>
<bew> ✨
<FromGitter>
<bew> @girng it's probably not web-based, is it @elorest ?
<FromGitter>
<bew> or if it is, Crystal would be on the backend, not front end
<FromGitter>
<elorest> @bew It’s a chromium app with crystal rendering the backend instead of node like with electron.
<FromGitter>
<bararchy> @elorest really cool, what ui lib you use ?
<FromGitter>
<elorest> It’s actually pretty fast even on arm.
<FromGitter>
<elorest> We
<FromGitter>
<girng> "crystal rendering the background", but how?
<FromGitter>
<girng> with what
<FromGitter>
<bew> backend, not background
<FromGitter>
<girng> oh oops
<FromGitter>
<girng> wow, fail
<faustinoaq>
@girng I guess they can use crystal with a native UI as well, crystal is not only for web development ;)
<FromGitter>
<girng> really interesting
<FromGitter>
<elorest> It just boots straight up to xorg launching the chromium app with no desktop manager or display manager.
<FromGitter>
<elorest> Only takes about 12 seconds but I think I can get that down further with a Yocto build.
<FromGitter>
<girng> @faustinoaq how did u just randomly find that lol. nice one.
<faustinoaq>
for most developers teams web development is easier and fast though ;)
<faustinoaq>
@girng @elorest is a pretty nice guy, he is using https://amberframework.org in production +100
<faustinoaq>
and because that thing makes me happy, right now I'm working on a bunch of nice features and fixes for amber, and I will publish some of them very soon ;)
<FromGitter>
<elorest> :)
<FromGitter>
<girng> :)
alex`` has joined #crystal-lang
<FromGitter>
<unn4m3d> Ббюь
<FromGitter>
<unn4m3d> Би юл до юбкой
<FromGitter>
<unn4m3d> Sorry
qard has quit [Ping timeout: 264 seconds]
<FromGitter>
<sdogruyol> Morning 👋
<FromGitter>
<girng> morning!
<FromGitter>
<Jens0512> Morning
<faustinoaq>
Morning! 00:50 here ;)
<FromGitter>
<Jens0512> Haha, still morning i guess :D
<FromGitter>
<sdogruyol> 08:50 :)
<FromGitter>
<sdogruyol> It's great to be in GMT timezone, literally the middle of the world in timezones 💃
<crystal-gh>
[crystal] sdogruyol pushed 1 new commit to master: https://git.io/vxhOP
<crystal-gh>
crystal/master 72ce28f Ata Kuyumcu: Fixed OpenSSL bindings to recognize LibreSSL (#5676)...
<crystal-gh>
[crystal] sdogruyol closed pull request #5420: Parser: make an error on unbalanced end brace '}' in macro body (master...fix/crystal-parser/error-unbalanced-end-brace-in-macro) https://git.io/vbDlx
<FromGitter>
<j8r> @straight-shoota you are right!
<FromGitter>
<straight-shoota> @jlebray putting the .a file in lib path and adding `--static` to the compiler should do the trick, although static linking is not properly supported except on alpine linux
<crystal-gh>
[crystal] sdogruyol closed pull request #5930: Raise syntax error when method argument name is keyword (master...fix/crystal/dont-use-invalid-internal-arg-name) https://git.io/vxQKZ
<FromGitter>
<jlebray> @straight-shoota I see, thank you. I’ll cross my fingers then 😄
That_Guy_Anon has quit [Quit: Leaving]
leucos has joined #crystal-lang
<FromGitter>
<cilquirm> Hi, i'm writing a little service that tries to connect to the GitHub API via HTTP client, and I keep getting this error: ⏎ `Exception: SSL_connect: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version (OpenSSL::SSL::Error)`
<FromGitter>
<cilquirm> I'm using Crystal 0.24.2 via Homebrew and I believe it has something to do with the older version of OpenSSL on Mac OS X 10.12 ( which I'm on ), but not sure how to get past the error
<FromGitter>
<straight-shoota> installing openssl with homebrow should fix it
<FromGitter>
<cilquirm> Thanks @straight-shoota . I did install OpenSSL via Homebrew but it would install `keg-only` despite pushing `--force` onto it, but the issue has a ton more clarity on it.
<Jenz>
I really did try to type that in one message
<crystal-gh>
[crystal] bcardiff pushed 1 new commit to master: https://git.io/vxhb4
<crystal-gh>
crystal/master 24c5330 Carlos Donderis: Added documentation for Kernel#sprintf method (#5914)...
jxv has joined #crystal-lang
flaviodesousa has quit [Ping timeout: 240 seconds]
<FromGitter>
<bew> @sdogruyol you're now a core member, is that new? Or did I missed sth?
<FromGitter>
<DRVTiny> Hi4all! Who knows, is it planned to be fixed somehow or no? ⏎ x : UInt16 ⏎ x=7 ⏎ ⏎ 1) leads to exception (Crystal cant make "type inference" on constant "7" and thinks that 7 is Int32) [https://gitter.im/crystal-lang/crystal?at=5ad0c4dadf3e0fb547d3de6f]
<FromGitter>
<sdogruyol> It's new @bew
<FromGitter>
<DRVTiny> If x is UInt16, why crystal thinks that 7 on the right hand is Int32? It is very annoying and stupid IMHO
<FromGitter>
<DRVTiny> literal is a literal - it is not Int32, UInt16 of Float64. If literal assigned to variable whose type is known - literal must be casted to the same type. ⏎ 7_u16 is crazy, absolutely awful think
<FromGitter>
<bew> Jenz: it means that the block you pass to fetch should either return a String or not return at all (e.g: by raising an exception)
<FromGitter>
<bew> The `NoReturn` is a special type, "returned" by `exit` or `raise` for example. It's not really returned, but the compiler need to know its type.
<FromGitter>
<bew> Jenz: So for example if you have `a = rand(10) > 5 ? 1 : raise "error"` the type of `a` will be `Int32 | NoReturn`, and the compiler cab safely say that on the next lines, `a` can only be `Int32`. When doing `a + 1` later, the compiler will know that this line can only execute when `a` is `Int32`, as otherwise the raise would have interrupted the normal execution flow.
snsei has quit []
That_Guy_Anon has joined #crystal-lang
<FromGitter>
<straight-shoota> hm, every method call can potentially raise, so `NoReturn` is usually implicit. It doesn't make sense to declare it explicitly, unless the method/block never returns.
<Jenz>
I've never seen it used like that before
<Jenz>
Only in `exit` I believe
<oprypin>
that's not what NoReturn is
<oprypin>
if you have `a = rand(10) > 5 ? 1 : raise "error"` the type of `a` will be `Int32`
<oprypin>
thats it
<FromGitter>
<straight-shoota> exactly
<FromGitter>
<straight-shoota> `NoReturn` is never included in a union type
<FromGitter>
<bew> Yes but implicitly noreturn will be there
<FromGitter>
<straight-shoota> And that block type is the only instance of this in the entire stdlib.
<oprypin>
I suspect that this is invalid, yes
<oprypin>
bew, with that type of explanation you may as well go adding NoReturn in every single case
<FromGitter>
<bew> That's true, 'was trying to find a simple example to explain what is NoReturn, but yeah it does justify the need to write it anywhere
<FromGitter>
<bew> Someone do a pr to remove it?
jxv has quit [Quit: string can snapped]
wuehlmaus has quit [Quit: Lost terminal]
<FromGitter>
<codenoid> hi
<FromGitter>
<codenoid> how i can change the content of a file
<FromGitter>
<codenoid> without change the last modified date data
<FromGitter>
<bew> Why not?
<FromGitter>
<codenoid> bcoz i won't' change the last modified date
leucos has quit [Ping timeout: 245 seconds]
<FromGitter>
<codenoid> helow
That_Guy_Anon has quit [Remote host closed the connection]
<FromGitter>
<codenoid> sorry wrong place
<FromGitter>
<bew> To change the content of a file you just open it for writing and write things to it (like an io)
<FromGitter>
<bew> You cab also go to a specific position in the file to make your changes if you know where to go
<FromGitter>
<bew> The last modified date is automatically set when you make changes to a file
<FromGitter>
<bew> I don't think you can bypass that.
<FromGitter>
<bew> You "could" set the modified date back yourself afterwards, but I don't see any valid use-case for this
wuehlmaus has joined #crystal-lang
faustinoaq has quit [Quit: IRC client terminated!]
guilleiguaran has joined #crystal-lang
<FromGitter>
<codenoid> yes
<FromGitter>
<codenoid> i just set last modified date
<FromGitter>
<girng> good morning!
<crystal-gh>
[crystal] RX14 closed pull request #5869: Add path to UNIXSocket created by UNIXServer (master...jm/fix/unix-server-path) https://git.io/vxEWx
<oprypin>
i wouldn't say anything is passed by anything, you just give it a piece of code and `{{ }}` is "paste that piece of code"
<oprypin>
just `a` is invalid because there is never any variable called `a`
<FromGitter>
<girng> well, i was told Namedtuples are passed by value
<oprypin>
what you pass to the macro is available only in macro context. the purpose of a macro is to generate code. generating code can't depend on runtime values
<FromGitter>
<j8r> macro is at compile time, that's a different story with `def` etc
<FromGitter>
<j8r> think macro generate valid "Crystal text code"
<FromGitter>
<j8r> that will compile after being generated, like any code
<FromGitter>
<bew> In your def example, the mapping macros receives `e` (literally) not the namedtuple (`{id: Int32}`)
<oprypin>
girng, JSON.mapping is a macro that expects a literal. you passed "e" to it
<FromGitter>
<girng> YES
<oprypin>
[20:33:54] <oprypin> what you pass to the macro is available only in macro context. the purpose of a macro is to generate code. generating code can't depend on runtime values
<FromGitter>
<bew> The mapping macros are expanded at compile time
<FromGitter>
<girng> BUT E is a COPIED VALUE
<FromGitter>
<girng> passed by Value!
<FromGitter>
<bew> The namedtuple (with the def) is passed at runtime
<oprypin>
I am out
<FromGitter>
<bew> Compile time is before runtime
<FromGitter>
<bew> Compile time is when you compile the program, runtime is when you execute the program
<FromGitter>
<bew> They are different world, the macro world and the execution world are different
<FromGitter>
<girng> i understand the difference between compile and runtime. i just don't understand why effect the parameter passing. especifally if the namedtuple is being passed by value (which is copying the data). in my mind, it's doing the exact same thing the macro is doing (copying the data)
<FromGitter>
<girng> where it stems my confusion from
<FromGitter>
<girng> but for other types that are generated on the heap / not passed by value, then i could understand because it's passed by reference
<FromGitter>
<girng> and passing by reference is NOT copying the data. so macro would work / make sense to me
<FromGitter>
<girng> hope that clears up where i'm coming from
<FromGitter>
<ezrast> @girng macros are not methods and you do not pass variables to them, by value, reference, or otherwise. The arguments to macros are pieces of language syntax, devoid of context.
qard has joined #crystal-lang
<FromGitter>
<ezrast> you can only access those arguments inside of `{{ }}` or `{% %}`
<FromGitter>
<girng> @ezrast yeah understood. just not why my regular def method isn't (when it's essentially being passed a copied value). of which, the macro is being passed a copied value too.
<FromGitter>
<ezrast> oh, because the `mapping` macros needs to know what your parameters are in order to expand correctly. Just passing it `e` doesn't give it that information.
<FromGitter>
<ezrast> yeah, what oprypin said
<FromGitter>
<bew> in your early example @girng you're passing `e` to the mapping, not the value of `e`
<FromGitter>
<bew> yeah nice one oprypin
<FromGitter>
<girng> okay i well i don't think i understand what pass by value means
<FromGitter>
<girng> obviously i think it's doing something it doesn't
<FromGitter>
<girng> from your examples, that's def not what i thought was happening
<FromGitter>
<bew> value/reference thing is during runtime only
That_Guy_Anon has joined #crystal-lang
<FromGitter>
<j8r> the `.mapping` are not casual methods, they are macros
<FromGitter>
<j8r> that's why there are explanations about macros @girng
<FromGitter>
<bew> having the crystal-expanded version of the code given in carc.in would help I think (self-promotion: #5821 ^^)
<FromGitter>
<bew> yes... no... it depends, what are you trying to do?
<FromGitter>
<ezrast> `JSON.mapping` defines a constructor for you but it takes a JSON parser as an argument; if you want to instantiate the class with values you provide yourself you'll need to define that constructor.
<FromGitter>
<styler1972> because if i don't specify a constructor at all i get this: ⏎ ` ⏎ no overload matches 'MyClass.new' with type Hash(String, Bool | Bool::Null | Float32 | Float64 | Float::Null | Int16 | Int32 | Int64 | Int8 | Int::Null | String | String::Null | Time | Time::Null | UInt16 | UInt32 | UInt64 | UInt8) ⏎ Overloads are: ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5ad1039b080a3850532cacdb]
<oprypin>
D:
<FromGitter>
<ezrast> Did you... monkey patch `Bool`?
<FromGitter>
<bew> @styler1972 how are you calling the constructor?
<FromGitter>
<styler1972> through `.to_json`
<FromGitter>
<styler1972> I did not monkey patch Bool, no
<FromGitter>
<girng> do you have a JSON.mapping in your class?
<FromGitter>
<ezrast> wth is a `Bool::Null`?
<FromGitter>
<bew> show us some code @styler1972, because currently I don't understand what you're doing
<FromGitter>
<girng> i've never seen that many types in an overload error and i've been around the block
<FromGitter>
<Sija> @styler1972 without dedicated constructor you’d need to use `MyClass.from_json`
<FromGitter>
<Sija> sth along the lines of `MyClass.from_json({ “foo” => “bar” }.to_json)` if you don’t want to build the json string by hand
<FromGitter>
<styler1972> Ah that makes sense
<FromGitter>
<styler1972> my code has a changed a bit since i originally asked
<FromGitter>
<styler1972> i broke the json mappings out of my data model into a ui model
<FromGitter>
<styler1972> im inheriting from ActiveRecord::Model, which might be doing strange things
<FromGitter>
<styler1972> yeah that would have been ideal
alex`` has quit [Ping timeout: 256 seconds]
<FromGitter>
<styler1972> btw.. i dont think i've ever been so giddy about programming as i have been in crystal.. love it so much. im learning it on a side project but i plan on using it for everything once i feel confident working in it as i do with other languages
<FromGitter>
<Sija> yup, crystal is addictive (;
<FromGitter>
<girng> @styler1972 praise
<FromGitter>
<styler1972> actually i updated the SO post
<FromGitter>
<styler1972> This makes no sense at all
<FromGitter>
<styler1972> ``````
<FromGitter>
<styler1972> It must be of type Int64, not Int64 is what i'm reading :/
<FromGitter>
<ezrast> What it's saying is it must be of type Int64, not one of a bunch of different types that can't be narrowed down at compile time
<FromGitter>
<styler1972> but isnt this explicitly saying the type should be In64?