<FromGitter>
<naqvis> > *<oprypin>*https://crystal-lang.org/api/master/Array.html#[]=(index:Int,count:Int,values:Array(T))-instance-method reeeeeally should accept Indexable :( ⏎ ⏎ Provided you want this method to sequentially copy elements :P
_whitelogger has joined #crystal-lang
alexherbo2 has joined #crystal-lang
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
postmodern has quit [Quit: Leaving]
_whitelogger has joined #crystal-lang
alexherbo23 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 256 seconds]
alexherbo23 is now known as alexherbo2
<riffraff169>
i have this: opcodes = {} of String => Array(Int32)
<riffraff169>
Error: no overload matches 'Array(Int32)#[]=' with types Mode, Int32
<jhass>
riffraff169: so modeval is not a string but presumably an enum called Mode
<riffraff169>
yeah, there it is
<riffraff169>
so modeval.to_i
<jhass>
that would turn it into an Int32, not a String
<riffraff169>
yeah, modeval should be an int
<riffraff169>
the array is "brk" = [ 234,-1,-1,-1,-1 ]
<jhass>
Oh, you're right, I got confused by the hash, sorry
<riffraff169>
so the array is a bunch of ints, probably -1 (not within 0..255)....yeah
<riffraff169>
ok, got past that with .to_i...missing hash key now....so, it wont automatically create the hash key....yeah, just like ruby, check if key exists, if not, create the entry, then add the data, otherwise modify the data
<riffraff169>
gotcha
<jhass>
yeah
<jhass>
Hash(String, Array(Int32).new {|h, k| h[k] = [] of Int32 } works too, just like ruby
<riffraff169>
ok, here is one of the alternates we were talking about yesterday: include? vs has_key? which is preferable? or does one not even exist?
<jhass>
include? doesn't exist at all :P We got Enumerable#includes?, son on Hash you'd check for .includes?({key, value}) which is probably not what you want
<riffraff169>
yeah, i just want to see if the key is present for now, if not, create it
<jhass>
has_key? it is, or use the "auto creating" hash like I mentioned above
<riffraff169>
hmm, i havent encountered that expression before, so im trying to understand it...where does h and k come from?
<FromGitter>
<Blacksmoke16> `h` is a reference to the hash itself and `k` is the missing key
<riffraff169>
thanks for the help...working with a kind of a combination of a dynamic and static language is kind of weird
<riffraff169>
ha ha!...i got it....doing a little code generation, the output will be a .cr file that can be included...each code has a list of modes it is valid in, and invalid ones are -1
<riffraff169>
now to output the data, pretty printed to the file...would like to convert numbers that arent -1 to hex, but not really necessary
<riffraff169>
so im going to use a makefile for some prerequisites (like this opcode generator)...would it be better if the makefile did a shards build and run? or would plain crystal run be better? not sure on that part
<riffraff169>
basically a dependency....if the pre-generated files have changed, then recreate the code files from the data before running the main build
lunarkitty has quit [Ping timeout: 244 seconds]
<FromGitter>
<Blacksmoke16> is this project meant to be installed? or run on its own
<riffraff169>
the main project will probably be installed, but the small program im writing right now as a prereq of the project will just be run in the source tree itself, if necessary
<FromGitter>
<Blacksmoke16> because there is a `postinstall` step you can do it in
<riffraff169>
upon distribution i will provide the generated file, kind of like difference between `make clean` and `make distclean`...
<riffraff169>
well, this would be prebuild actually
<FromGitter>
<Blacksmoke16> fair enough
<riffraff169>
do people tend to use makefiles? or shards only? some programming languages (java i believe) have their own totally separate project build ecosystem
<FromGitter>
<Blacksmoke16> makefiles are pretty common
<riffraff169>
ok, thats fine, im pretty familiar with those
alexherbo2 has quit [Ping timeout: 256 seconds]
<riffraff169>
printing out my final opcode list ``` outfile << " opcodes = {\n"
<riffraff169>
str = opcodes.keys.sort.each.join(",\n") do |opcode|
<riffraff169>
i like being able to chain methods like that, and use blocks/lambdas....python doesnt let me do that
<FromGitter>
<Blacksmoke16> i think the `.each` is redundant
<FromGitter>
<Blacksmoke16> could do `.sort.join`
<riffraff169>
yep, you are right, thanks
<riffraff169>
so now i have it generating my file as a module that will be included in another class..fantastic
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<FromGitter>
<Blacksmoke16> 👍
alexherbo2 has joined #crystal-lang
<FromGitter>
<Dan-Do> why does crystal http module encode the cookies?
<FromGitter>
<Dan-Do> I got JSESSIONID=0000N-X1lNeO_hMzfqNsEZVkJpY:19ciqlrd2 from the server, but crystal encode it to JSESSIONID=0000N-X1lNeO_hMzfqNsEZVkJpY%3A19ciqlrd2 before sending
<FromGitter>
<Dan-Do> It made me crazy 2 days debugging this
<FromGitter>
<Dan-Do> Can we have an option to tell client not encode, something like: ⏎ ⏎ ```client.encode_cookie = false``` ⏎ ⏎ Right now it's hidden, we have no idea about the encoding of cookie until looking at/debugging the source code. [https://gitter.im/crystal-lang/crystal?at=5f5a5622f51808513b34f5c0]
<FromGitter>
<grkek> How does one define a heredoc?
<FromGitter>
<Blacksmoke16> just change it to whatever you want
<FromGitter>
<Blacksmoke16> `<<-FOO`
<FromGitter>
<grkek> Oh nice :)
<jhass>
just make one up, the token is <<-
<FromGitter>
<grkek> Can I do something like JSX in crystal?
<FromGitter>
<Blacksmoke16> heredocs support interpolation if thats what you mean
<FromGitter>
<grkek> No, what I mean is that
<FromGitter>
<grkek> can I literally write
<FromGitter>
<grkek> <Box></Box> as crystal syntax
<FromGitter>
<grkek> return <Box/>;
<FromGitter>
<grkek> the semicolon slipped sorry :p
<jhass>
no
<FromGitter>
<grkek> Why not?
<jhass>
because nobody wrote a preprocessor and tooling around it that would allow it
<FromGitter>
<grkek> Damn it
<FromGitter>
<Dan-Do> I am interesting in web javascript front-end preprocessor too :)
<FromGitter>
<grkek> It would be interesting if I wrote a preprocessor for it tbh
<FromGitter>
<grkek> just imagine building guis
<FromGitter>
<Dan-Do> We already had shards as: Jinja(Twig)/Crinja, Mustache/Crustache
<FromGitter>
<grkek> Meh they don't look as comfy as jsx
<FromGitter>
<Dan-Do> Hint for you, shard "crystal-nodejs". With that I render the front-end code on server side. So, one code for both front/back end
<FromGitter>
<Dan-Do> lol
alexherbo26 has joined #crystal-lang
alexherbo2 has quit [Read error: Connection reset by peer]
alexherbo26 is now known as alexherbo2
alexherbo24 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 246 seconds]
alexherbo24 is now known as alexherbo2
alexherbo2 has quit [Ping timeout: 256 seconds]
alexherbo2 has joined #crystal-lang
lunarkitty has joined #crystal-lang
lunarkitty is now known as lunarkitty7
alexherbo2 has quit [Ping timeout: 260 seconds]
<raz>
grkek: JSX is ultimately just syntactic sugar for a method call. can be done with a simple string preprocessor easily.
<raz>
but copying ideas from javascript is usually a bad idea. because their ideas tend to be bad. all of them.
<raz>
in fact, if you were to design a language with the only goal of making it the exact opposite of javascript in every way, it would probably become a pretty good language
sagax has quit [Remote host closed the connection]
sagax has joined #crystal-lang
sorcus has quit [Ping timeout: 240 seconds]
sorcus has joined #crystal-lang
sorcus has quit [Ping timeout: 244 seconds]
postmodern has joined #crystal-lang
sorcus has joined #crystal-lang
sorcus has quit [Ping timeout: 272 seconds]
sorcus has joined #crystal-lang
<FromGitter>
<wyhaines> I haven't put too much thought into it, but I think that one could build a JSX-like templating library, using Crystal, without doing anything very esoteric.
<raz>
well, to each their own. i hate such language mixes with passion. editors and linters struggle. humans struggle with the inevitable rabbit holes of nested complexity. etc.