<FromGitter>
<Blacksmoke16> idt that would work ⏎ ⏎ > Only primitive integer types, reference types or nilable reference types can be used with an Atomic type.
<FromGitter>
<Blacksmoke16> `Bool` is a `Value` type
<FromGitter>
<636f7374> @Blacksmoke16 Thank you very much.
<FromGitter>
<636f7374> @Blacksmoke16 Another stupid question, how does C++ or Java `volatile` type do it in Crystal? Do I have to use Mutex?
<FromGitter>
<636f7374> There is a common problem with visibility of variables in multithreaded environments. Let's assume that we have a shared variable (or object) that is being accessed by two different threads (each thread on its own processor). ⏎ If one thread updates the variable/object, we cannot know for sure when exactly this change will be visible to the other thread. The reason why this happens is because of CPU caching.
<FromGitter>
<Blacksmoke16> a mutex would be what you want in order to ensure only 1 thread access something at a time
<FromGitter>
<Blacksmoke16> ofc this is only relevant if you're using the MT opt in feature
<FromGitter>
<Blacksmoke16> 1 fiber*
<FromGitter>
<636f7374> @Blacksmoke16 Ok thanks a lot. :)
<eiro>
talk about the ruby * that isn't supported so
<eiro>
i can't write index, *chars = "hello".scan(/../) # would have been nice
<FromGitter>
<MrSorcus> `pp String.new peek[16, index]` - i thought it should return `Бланки/10_Направление в стационар_1 ЛИСТ.pdf`, not `Бланки/10_Направление в стационар_1 ЛИСТ.pdf\n123456789009876`...
<eiro>
i just don't get it ... transforming a simple, lightweight protocol like irc to a gitter stream ....
<FromGitter>
<MrSorcus> Oops, forget it. 😆
eiro has quit [Quit: cya]
alexherbo2 has joined #crystal-lang
<FromGitter>
<asterite> Yes, `index, *chars = ...` was already implemented by the awesome HertzDevil, but it didn't go through 1.0. But I'm sure it will be included in upcoming versions
<FromGitter>
<asterite> Also, it needs to be `"02helo".scan(/../).map(&.string)`
libneko[m] has joined #crystal-lang
chachasmooth has joined #crystal-lang
chachasmooth_ has quit [Ping timeout: 246 seconds]
shalokshalom has quit [Ping timeout: 246 seconds]
<FromGitter>
<riffraff169> so, building with `shards build`, i presume that is the proper way for a whole project
<FromGitter>
<Blacksmoke16> that builds the targets you have defined in your `shard.yml`
<FromGitter>
<riffraff169> you just set a target of one file, that `require`s all the other files (assuming you just have one binary output)
<FromGitter>
<riffraff169> not like c where you specify all the files you need to compile and build together into one output
<FromGitter>
<Blacksmoke16> right
<FromGitter>
<riffraff169> basically im having a bunch of requires in my main with all the files to be included...since they are all classes, they arent actually called until i create a class and use it
<FromGitter>
<riffraff169> ok
<FromGitter>
<riffraff169> still getting my way around crystal programming...never dug in that deep in ruby either, so never really used modules
<FromGitter>
<Blacksmoke16> at a high level you should use them to namespace your types and stuff
<FromGitter>
<Blacksmoke16> e.g. if you do `class SomeClass` then some other shard does the same thing you'll have problems
<FromGitter>
<riffraff169> although looking at the shards source, i noticed that it just does `require './config'`, with an ending `.cr`
<FromGitter>
<Blacksmoke16> so you cod `class MyLib::SomeClass`
<FromGitter>
<Blacksmoke16> you should*
<FromGitter>
<Blacksmoke16> modules can also be used as interfaces and/or to include methods into various other types as a form of composition
<FromGitter>
<riffraff169> so i have a struct, loading with yaml like i talked about yesterday, so a hash of structs
<FromGitter>
<riffraff169> ill have to do things with the data, of course...i have a class that loads up all the data into an instance var....i was going somewhere with this, lost my train of thought
<FromGitter>
<riffraff169> ok then this question....enums, can they be loaded from yaml with `.from_yaml`?
<FromGitter>
<Blacksmoke16> sure
<FromGitter>
<riffraff169> so i would use `getter a : MyEnum`, then have i presume the fully qualified enum in the yaml like `a: MyEnum::TEST`
<FromGitter>
<Blacksmoke16> by default you would want `a: test` in your yaml
<FromGitter>
<Blacksmoke16> i.e. the string representation of it
<FromGitter>
<riffraff169> ah, ok
<FromGitter>
<riffraff169> fantastic, that worked perfectly
zorp has joined #crystal-lang
andremedeiros has quit [Read error: Connection reset by peer]
andremedeiros has joined #crystal-lang
<FromGitter>
<lodenos> Hello everyone I’ve a question about HTTP::Headers, I would to use the feature from HTTP Content-Range form https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range for build my request ⏎ ⏎ ```response = HTTP::Client.get route_api, HTTP::Headers { "Content-Range" => "bytes=0-“ }``` ⏎ ⏎ but it’s seem doesn’t work I get all data, what’s wrong I don’t have really understand,
<FromGitter>
<Blacksmoke16> @straight-shoota would it be worth having another test case for like `name : String? = "Jim"`. E.g. `name: ~` should be `nil`, `name:` should be `nil`, `name: John` should be `John`, and if it's missing it should be `Jim`
<FromGitter>
<Blacksmoke16> `name: ""` should be`""`
ua has quit [Ping timeout: 240 seconds]
ua has joined #crystal-lang
<FromGitter>
<riffraff169> is `a : Array of Int32` sufficient? how about if i know that exact number of elements in the array, say 10?
<FromGitter>
<Blacksmoke16> `a : Array(Int32)`, this is just the type. Knowing the size only helps when first creating one
<FromGitter>
<riffraff169> another question, can you build up regexes? like, `a1 = /\d+/`, `a2 = /\s+/`, `a3 = a1 + a2`
<FromGitter>
<riffraff169> ok so i would do `Array(Int32)` instead of `Array of Int32`, or are they both the same
<FromGitter>
<oprypin:matrix.org> @riffraff169: yes build them up, why not
<FromGitter>
<oprypin:matrix.org> @riffraff169: these are different things. to avoid confusion just forget about the `of` syntax
<FromGitter>
<Blacksmoke16> `Array of Int32` pretty sure this isnt valid syntax
<FromGitter>
<riffraff169> ok, so `+` works fine, i dont have to do interpolation like `a3 = /#{a1}#{a2}/`
<FromGitter>
<oprypin:matrix.org> @riffraff169: i don't know, try and see
<FromGitter>
<Blacksmoke16> not quite
<FromGitter>
<riffraff169> sure, ill do that
<FromGitter>
<Blacksmoke16> `+` is an alias for `union` iirc, so you end up with like `\d+|\s+`
<FromGitter>
<Blacksmoke16> so the interpolation one is technically correct iirc
<FromGitter>
<riffraff169> hmm, maybe as @oprypin:matrix.org said, create strings and convert to regex afterwards
<FromGitter>
<riffraff169> so like `Regex.new(regex_string)`
<FromGitter>
<Blacksmoke16> cant just create the end result regex without using these parts?
<FromGitter>
<riffraff169> well, the parts can be used in other portions, and i dont want to duplicate the strings
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Max SendQ exceeded]
HumanG33k has joined #crystal-lang
<FromGitter>
<Blacksmoke16> fair enough
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
shalokshalom has joined #crystal-lang
<straight-shoota>
@Blacksmoke16 > would it be worth having another test case for like `name : String? = "Jim"`. E.g. `name: ~` should be `nil`, `name:` should be `nil`, `name: John` should be `John`, and if it's missing it should be `Jim`
<straight-shoota>
I think that should all be covered already in that spec
<FromGitter>
<Blacksmoke16> 👍 i didnt look thru all them, just that in the spec you added it wouldnt be nilable
<straight-shoota>
ah, you're taking about nilable type, sry didn't catch that
<FromGitter>
<Blacksmoke16> yea, like nilable type + explicit nil
<straight-shoota>
I don't think that matters here
<FromGitter>
<Blacksmoke16> 👍 ight
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
_ht has quit [Remote host closed the connection]
<FromGitter>
<lodenos> @Blacksmoke16 I’ve a question for u if u know, how work Array behind, it’s a linked list or a perfect continus pointer realloc when we use the operator << (append)
<oprypin>
lodenos, "continuous pointer realloc"
<FromGitter>
<Blacksmoke16> one of the overloads allows you to specify initial capacity as well
<FromGitter>
<ryanstout> @ straight-shoota I don't follow, pass in an uninitialized something for value?)
<straight-shoota>
na, not really useful I guess
<FromGitter>
<ryanstout> ok, so the next question then. If you can't do it in the safe part of the language, is there a way to do it with Pointer(UInt16).malloc?
<FromGitter>
<ryanstout> looks like all the `malloc` methods initialize also
<straight-shoota>
The build method posted by Blacksmoke16 should work for that
<FromGitter>
<ryanstout> ok, I misread the docs on that. I think I can make that work
<FromGitter>
<ryanstout> thanks
<straight-shoota>
Like `ary = Array(T).build(size) { size }`
<FromGitter>
<ryanstout> thanks everyone, that shaved off 5% of the run time :-)
<FromGitter>
<lodenos> This is really nice for the C binding
alexherbo2 has quit [Quit: Ping timeout (120 seconds)]
alexherbo2 has joined #crystal-lang
hendursaga has quit [Remote host closed the connection]
hendursaga has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 240 seconds]
<FromGitter>
<Daniel-Worrall> Can you have the same C link called by a different name? So for example you could define the same links that the stdlib does and not worry about conflicts