<FromGitter>
<Blacksmoke16> `arr = [] of Array(String)`
<FromGitter>
<renich> Ah, OK
<FromGitter>
<renich> Thanks @Blacksmoke16
<FromGitter>
<Blacksmoke16> np
<coderobe>
I use a macro for adding type information to an array, among other things, so `[foo]` turns into `[foo] of Foo | Bar`, however calling the macro with an empty array still results in an `for empty arrays use '[] of ElementType'` compiler error - despite the macro attaching type information. is this intentional?
<FromGitter>
<Blacksmoke16> yes, have to have a type on the arra
<FromGitter>
<Blacksmoke16> its even more needed on empty arrays because the type cannot be inferred from the contents of the array
<coderobe>
the macro attaches the type information
<coderobe>
shouldn't the macro run *before* type checking? as they're compile-time..
<FromGitter>
<Blacksmoke16> type checking happens at compile time too
<FromGitter>
<Blacksmoke16> so type checking *could* be happening *before* the macro runs?
<coderobe>
well yes
<FromGitter>
<Blacksmoke16> got some example code?
<coderobe>
as it stands, this definitely turns into Array(UInt16 | UInt8 | Nil) at compile time
<coderobe>
however, swapping the commented lines, it turns into a compile-time error ;)
<coderobe>
to me it seems like this should work with empty arrays as well, as the type is correctly attached, and *then* be type-checked
<coderobe>
especially considering that the document describes macros as `Macros are methods that receive AST nodes at compile-time and produce code that is pasted into a program`
<coderobe>
eh, remove the typeof() around the macro call in the commented line of my example, that was unintentional
<coderobe>
not that it changes anything, though
<coderobe>
so the argument is not a valid expression on its own, but the generated code must be valid according to the docs, which it is
<coderobe>
as `[] of UInt8 | UInt16` is valid, so is `[1_u8] of UInt8 | UInt16`, both of which would be generated by an `attach_type([])` and `attach_type([1_u8])` respectively, given my example macro
<FromGitter>
<Blacksmoke16> hmm
<FromGitter>
<Blacksmoke16> the issue is the actual array you are passing it
<FromGitter>
<Blacksmoke16> since its empty
return0e has quit [Remote host closed the connection]
<FromGitter>
<Blacksmoke16> so that it wont try to evaluate the empty array before executing the macro
<coderobe>
yes, my argument is that it shouldn't evaluate it before running the macro either way
<FromGitter>
<Blacksmoke16> :shrug: but it does
<coderobe>
i'm here to find out why.
<coderobe>
especially considering that other invalid expressions like undefined constant garbage is fine
<coderobe>
ie 'my_macro(FOOOO)' does not throw an error when FOOOO is, in fact, not defined, and properly fills in the macro, turning it into valid code
<coderobe>
when FOOOO is, e.g., a partial class name
<coderobe>
so this just seems like an oversight
<coderobe>
because as far as i can tell, any arbitrary input should be fine as macro argument as long as the produced code is not garbage
<FromGitter>
<Blacksmoke16> Probably due to order of compile
<FromGitter>
<Blacksmoke16> Which I don't know enough about
non-aristotelian has quit [Quit: non-aristotelian]
<FromGitter>
<pitosalas> a = [1,2,3]
<FromGitter>
<pitosalas> Is there a similar method to drop the first element of an array?
<FromGitter>
<Blacksmoke16> by default error message would be like `'enddate' should be greater than {{date}}` where `{{date}}` is whatever `startdate `was
<FromGitter>
<Blacksmoke16> ill leave this question here before i go to bed, what syntax would you rather
akaiiro has quit [Remote host closed the connection]
<FromGitter>
<dscottboggs_gitlab> so... how to convert from a Bytes which contains utf-8 codepoints to a String?
<FromGitter>
<dscottboggs_gitlab> never mind of course I figure it out as soon as I ask
<shmibs>
ラバーダック
<FromGitter>
<ljuti> @Blacksmoke16 I’d rather put the annotations on separate lines
rohitpaulk has joined #crystal-lang
ashirase has quit [Ping timeout: 264 seconds]
ashirase has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
<FromGitter>
<vladfaust> @Blacksmoke16 I prefer one line instead
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
DTZUZO has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
<FromGitter>
<j8r> @renich but we cant `[] of [] of String`, so I prefer `Array(String)` and `Array(Array(String))`
<FromGitter>
<j8r> can someone remind me what the point of having this `of` syntax?
<FromGitter>
<r00ster91> it's just an alias to e.g. Array(String).new
<FromGitter>
<Manu-sh> hi, the last time i had made a question but no one answer me now i want repropose why this expression raise an error (I suspect the reason is that this expression can not be evaluated at compilation time) ? And how can i do this with crystal ? ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5bf004e880e46b4266c64ba0]
<FromGitter>
<j8r> I don't think its only an alias @r00ster91 , someone told me it has another feature. If it's really just an alias, we should remove it
<FromGitter>
<j8r> this syntax hides the real type behind the variable, when we `typeof` it
<FromGitter>
<j8r> @Manu-sh what?! This isn't valid, obviously. You might succeed with macros
<FromGitter>
<Manu-sh> isn't obvius
<FromGitter>
<j8r> @Manu-sh Types are know at compile time, you can't have this type of runtime operations
<FromGitter>
<swinSpo> This code works so far, but I would like to add other types than just String (like Integers or booleans / time ) without making the code too complicated
<FromGitter>
<swinSpo> One Issue I am having is that the Provider, the Config and ConfigNamespace seem to have a lot of repetition if I implement other data types (like Integers or booleans)
<FromGitter>
<swinSpo> because the config namespace would need to expose the config methods, and that would need to expose the provider methods
<FromGitter>
<vlazar> @j8r I've build simple Crystal hello world HTTP server for alpine using command like you've mentioned here, only with local alpine crystal image https://github.com/j8r/dockerfiles/tree/master/crystal-alpine#usage and server does seem to work without added `require "llvm/lib_llvm"` and `require "llvm/enums"` - is this really needed to run any app or is it for some programs only?
<FromGitter>
<j8r> The PR I've sent with the libunwind linking doesn't seem to work better, unfortunatly
<FromGitter>
<ljuti> @renich Did you figure it out?
<FromGitter>
<Blacksmoke16> o/ Lauri
<FromGitter>
<ljuti> Hello :)
<FromGitter>
<vlazar> Thanks Julien, I guess I'll always add these requires for now for safety. I've seen https://github.com/crystal-lang/crystal/pull/4872 and thought that maybe it's only needed if compiling Crystal itself
<FromGitter>
<Blacksmoke16> working on v0.5.0 now, will be some more nice changes coming your way
<FromGitter>
<Blacksmoke16> `include CrSerializer`, dropping the `::Json`
<FromGitter>
<Blacksmoke16> also dropping it in serialization options, `@[CrSerializer::Options(xx)]`
<FromGitter>
<ljuti> Nice 👍
<FromGitter>
<Blacksmoke16> class annotation is renamed to `ClassOptions`
<FromGitter>
<ljuti> I like the shortened syntax, much cleaner
<FromGitter>
<Blacksmoke16> indeed, should work out better. not going to worry about yaml so no need for the `::Json`
<FromGitter>
<Blacksmoke16> currently working on supporting more serialization options