<Rinkana>
Hmm, i don't want to append `.as()` to every call.
rohitpaulk has joined #crystal-lang
bmcginty has quit [Ping timeout: 240 seconds]
bmcginty has joined #crystal-lang
<FromGitter>
<villzor> Morning all! I'm trying to invoke a getter call to a lazily read property from inside a method call, e.g. ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Anyone knows how to accomplish this? [https://gitter.im/crystal-lang/crystal?at=59b5119e319100804e18c274]
rohitpaulk has quit [Ping timeout: 248 seconds]
<FromGitter>
<villzor> Ahh never mind I figured it out >_< I had written @ingredients which doesn't invoke the getter call. The above code works as expected... Sorry for bothering.
<Papierkorb>
Groogy: `LibC::Long` et al are supposed to mirror the sizes of their C counterparts
<Groogy>
yeah so (when windows is supported) it will be 32bit on Windows 64bit but 64bit on Linux/MacOS when the OS is 64 as well
<Groogy>
and 32bit when its a 32bit system
<Papierkorb>
anything else would at least be a severe bug
<Groogy>
yeah I will have to assume it should work like this, though would be nice with some docs on it since its quite useful for doing bindings
<RX14>
of course ia-32 and ia-64 are entirely unrelated processor architectures
<RX14>
why would intel make it simple
<Papierkorb>
ia64 is itanium, not x86
<Groogy>
well they say that theirs are compliant with Microsoft C++ and GCC
rohitpaulk has quit [Ping timeout: 240 seconds]
<RX14>
Papierkorb, yeah its annoying
<Papierkorb>
At least it's dead for good
<RX14>
well
<RX14>
i hope we're not stuck on x86 for the rest of my life
<Papierkorb>
The next thing needs to be "better", whatever that means
<Papierkorb>
And as far I hear, none other currently existing architectures are actually better
<RX14>
i've watched the mill architecture talks and they're really interesting
<RX14>
can't wait until they get to the FPGA and we can see if it's "real"
<Papierkorb>
> In addition, the size of a "long double" also varies by operating system. On Windows*, the size is 8 bytes by default. On Linux or Mac OS X, 10 bytes are used for the representation of a long double, although the allocated size may be larger (12 bytes on IA-32 Linux; 16 bytes elsewhere).
<Papierkorb>
wtf
rohitpaulk has joined #crystal-lang
<Groogy>
that's for memory alignment isn't it? Though feels unnessecary if you gonna allocate more why not just use all of it
<RX14>
because you get more performance by not?
<FromGitter>
<faustinoaq> Hi, When Crystal supports Windows how libraries and dependencies will work? Do we will need to install a bunch of dll before execute a crystal binaries?
<Papierkorb>
I wasn't referring to the alignment, which is fine. But that, again, Windows is different to everyone else
<Papierkorb>
faustinoaq, well, DLL hell like with every other program on Windows
<RX14>
oprypin, i doubt you could do anything in current crystal on windows
<oprypin>
how does txe iterate on it?
<RX14>
by implementing more in Crystal::System
<RX14>
IO is the big problerm
<RX14>
IO is the big problem
<RX14>
once we have that sorted out
<oprypin>
RX14, but how do we know that code works?
<RX14>
then the rest we can sort out slowly
<RX14>
oprypin, because it's taken from a fork that works
<RX14>
you eman the LibC base?
<oprypin>
i mean everything
<RX14>
you mean CI?
<RX14>
im not sure what you're asking
<oprypin>
no, i mean i could put some random code and say trust me this works on windows but i actually have no idea
<oprypin>
and neither do you when merging
<RX14>
so... CI
<RX14>
because thats what PR ci is for
<oprypin>
CI is only one of the ways to confirm it, but it's obviously missing for Windows
<RX14>
well a certain amount of trust is required
<RX14>
i don't see the issue myself
<RX14>
whats the point in putting something in which you know doesn't work
<oprypin>
the fact that we don't have Crystal working at all on Windows complicates so many things
<oprypin>
you can't properly work on it, you can't confirm it works
<RX14>
all we've merged is the LibC base and the linker stuff
<RX14>
and a few refactors
<RX14>
next thing to sort out is IO
<RX14>
and once we have IO we can start
<RX14>
also we can compile for windows with --prelude=empty
<RX14>
and just require whatever we need to test
<oprypin>
that's nice then
<oprypin>
maybe i should look into exception hierarchy
<RX14>
well whats the alternative?
<RX14>
oprypin, please do, i'd love a PR to remove that annoying Errno
<oprypin>
merge messy fork, then fix it up
<RX14>
yeah but fix it up never happens
<RX14>
it would remain as technical debt for a long time
<RX14>
slowing down everything on linux
<RX14>
which is bad for everyone
<RX14>
i know that we'd all refret it if we had duplicated every single platform-specific file
<RX14>
regret*
rohitpaulk has joined #crystal-lang
andrewzah has quit [Ping timeout: 240 seconds]
<oprypin>
hey, the situation with exceptions is not so bad. I think that `WinError < Errno` is, in fact, the right way to go, just with better names and a bunch of subclasses
<oprypin>
thats what python does kinda, but there are some fake relationships due to legacy
rohitpaulk has quit [Ping timeout: 240 seconds]
andrewzah has joined #crystal-lang
<RX14>
oprypin, i don't think we should keep errno
<oprypin>
rename it to OSError
<RX14>
i think that it's a very C way to do things
<oprypin>
it works very well in Python
<RX14>
and would have clearly not been the way to do things if we didnt have ruby or C heritage
<RX14>
i think the correct way is to have a seperate exception class for each type of error, *with machine-readable fields* and use those
<oprypin>
RX14, there are way too many possible kinds of errors, it's not worth making a class for each of them
<RX14>
perhaps there might be an abstract OSError
<RX14>
oprypin, well that's how it's done in java and C#
<RX14>
and it works just fine
<RX14>
i think it's one of the few parts of those languages which are well done
<RX14>
or more accurately, would translate well to crystal
<FromGitter>
<bararchy> We need more fine-grained errors for sure
<FromGitter>
<bararchy> right now half the code pash is `raise "ho no!!"`
rohitpaulk has joined #crystal-lang
ShalokShalom_ is now known as ShalokShalom
rohitpaulk has quit [Ping timeout: 248 seconds]
<FromGitter>
<faustinoaq> Hi people, I'm creating a new shard, `require "my-new-library"` vs `require "my_new_library"` both are valid, but which is more recommended? What are the shard name conventions?
<oprypin>
i thought `require "my-new-library"` is invalid. underscores is definitely the way to go
<RX14>
its not invalid
<oprypin>
faustinoaq, require "my_new_library" to get MyNewLibrary module. repository name can be anything
<RX14>
but it's atypical
<RX14>
what oprypin said
snsei has joined #crystal-lang
Inause has joined #crystal-lang
<Inause>
good morning 😊
<FromGitter>
<bew> hi!
snsei has quit [Remote host closed the connection]
Inause has quit [Quit: Yaaic - Yet another Android IRC client - http://www.yaaic.org]
andrewzah has quit [Ping timeout: 240 seconds]
weston has joined #crystal-lang
andrewzah has joined #crystal-lang
snsei has joined #crystal-lang
andrewzah has quit [Ping timeout: 248 seconds]
<Rinkana>
Is there any difference between to_unsafe and pointerof ?
andrewzah has joined #crystal-lang
andrewzah has quit [Ping timeout: 260 seconds]
weston has quit [Ping timeout: 240 seconds]
hightower3 has joined #crystal-lang
<oprypin>
Rinkana, yes. for a class, to_unsafe returns the pointer, pointerof returns the pointer to the pointer
<crystal-gh>
[crystal] asterite opened pull request #4945: GC.enable: raise if GC is not disabled (master...bug/gc-enable) https://git.io/v5PIf
<wmoxam>
Crystal only recently dropped support for versions < 3.6
andrewzah has quit [Ping timeout: 260 seconds]
* sp4rrow
those changes seem to be different then what I expected from the announcement
<hightower3>
Is our friend Ari back to working on Crystal or just doing minimal/maintenance work?
<sp4rrow>
was he gone?
<linuksz>
I want to parse a YAML file that has the following structure:
<linuksz>
filename1:
<linuksz>
keyword1:
<linuksz>
- date2
<linuksz>
- date1
<linuksz>
keyword2:
<linuksz>
- date3
<linuksz>
filename2:
<linuksz>
keyword3:
<linuksz>
- date4
<FromGitter>
<sdogruyol> ugh
<linuksz>
etc...
<linuksz>
The file can contain unlimited filename, with unlimited keyword and unlimited date.
<FromGitter>
<sdogruyol> that's not good
<linuksz>
The usage of YAML.mapping is not clear for me. There is a FileHistory class, and I want to use YAML.mapping for parsing the file. I created a HistoryOfFile class, that manages the keywords and dates. There is a Hash of String => HistoryOfFile. The keys are the filenames. Is it possible to parse the YAML file using YAML.mapping in the FileHistory class for building the hash that indexes the filenames, and using YAML.mapping for the
<FromGitter>
<sdogruyol> please use a gist
<linuksz>
history of each filename to convert it to HistoryOfFile ?
<Groogy>
use pastebin for stuff like that
<hightower3>
sp4rrow, yes, he left Manas and there was an announcement about it
<linuksz>
for 9 lines?
<Groogy>
yeah it's still better to put it in a gist/pastebin etc.
<linuksz>
ok, i will do it next time
<sp4rrow>
hightower3 do you have a link to that ?
<Groogy>
Also I haven't used YAML.mapping so no idea on how to answer that, I just read things manually
<sp4rrow>
I have been gone for a while and I missed that
<Groogy>
since I need to solve bit more complex references
<sp4rrow>
I think there was another YAML lib someone sent me about a year ago
<sp4rrow>
I am not sure if it is still maintained
<hightower3>
sp4rrow, can't find it now, but it was discussed in this chat as well, try searching the chat logs. (I can't remember when was it - maybe 2 months ago?)
<Groogy>
but yeahfrom what I get it should be possible?
<Groogy>
you just define that the type of the variable is a HistoryOfFile?
<linuksz>
the problem is that if i understood it well, in each variable in YAML.mapping represents a YAML key
<linuksz>
but
<linuksz>
the keys are filenames
<linuksz>
and there is a lot of them
<Groogy>
well the variable that holds the hash would be a Hash(String, HistoryOfFile) type right?
<linuksz>
Papierkorb: i will try it to read the file, but my program have to write it first. how can i dump it to YAML?
<Groogy>
to_yaml?
<linuksz>
and should the HistoryOfFile class have a YAML.mapping method in this case?
<Groogy>
yeah since you need to define the variables so it knows how to serialize them
<Groogy>
I think?
<Papierkorb>
yes
<linuksz>
but the problem is that the key names are the contents of the variables
<linuksz>
what should i do in that case
<linuksz>
?
rohitpaulk has joined #crystal-lang
<linuksz>
and YAML.mapping needs to know the key name that is different in every case
<Groogy>
if it's a Hash var then it puts the key name into the key part of the hash
<linuksz>
but what should i give as instead of key name to the argument of YAML.mapping?
sp4rrow has quit [Quit: Textual]
<Groogy>
in HistoryOfFile or FileHistory?
<linuksz>
HistoryOfFile
<Groogy>
The FileHistory has a collection of HistoryOfFile wich are identified by filenames right?
<linuksz>
yes {} of String => HistoryOfFile
<Groogy>
what entries in HistoryOfFile have different variables?
<Groogy>
because for one, Crystal doesn't support adding variables dynamically at runtime
<linuksz>
the history of file's data is this:
<linuksz>
@keywords = {} of String => Array(Time)
<linuksz>
the String is the keyword
<Groogy>
then that's how you define the type in the mapping as well
<Groogy>
Hash(String, Array(Time))
<Groogy>
done
sp4rrow has joined #crystal-lang
<linuksz>
ok, but what should i give to the arguments of YAML.mapping?
<linuksz>
it excepts something similar to this:
<linuksz>
something: Hash(String, Array(Time))
<linuksz>
YAML.mapping(
<linuksz>
)
<linuksz>
but there isn't 'something' key in the yaml file
<Groogy>
also ugh why does FreeType have to be so special with how it defines its enums. Can I define 1 byte chars somehow easily? Like '\8a' or something
andrewzah has joined #crystal-lang
<Groogy>
well you have to provide data to something, YAML probably doesn't write anything if there's nothing in there
<linuksz>
the YAML key name is the Hash's key
<RX14>
linuksz, you don't *need* to use YAML.mapping
<RX14>
you're trying to fudge it in where you shouldn't use it
<linuksz>
but how else can i do it?
<RX14>
if your dasastructure is truly a Hash(String, Hash(String, Array(String))) then thats what you parse from yaml
<RX14>
and thats the same datastructure your program should use internally
<RX14>
and for you, it seems to be the case
<linuksz>
no, because the HistoryOfFile defines methods
<RX14>
what is a historyoffile
<RX14>
in that case then you should define a def initialize(yaml : YAML::PullParser)
<RX14>
then use @foo = Hash(String, Array(String)).new(yaml)
<linuksz>
i am creating a paste. wait a moment
<RX14>
which gets you your deserialization
<Papierkorb>
or just split logic code from storage ♪
<RX14>
and the same for to_yaml
<RX14>
Papierkorb, or that
<RX14>
but it's perfectly possible to take both approaches
snsei_ has quit [Remote host closed the connection]
<linuksz>
the methods don't work
<Groogy>
anyway is there a way to create 8bit chars literals somehow? Need it for freetype binding which is super annoying in how they create their enums which are a bit bonkers
<Papierkorb>
Groogy: I take that as you'll be happy to build a freetype shard with bindgen after its next release :P (May take another week)
snsei has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
<Groogy>
hah oh yes definetly
<Groogy>
I am just doing this so I can get text rendering, it is not meant to be permanent (except the rendering part)
snsei has joined #crystal-lang
<Groogy>
let me know when you think bindgen can deal with freetype and I'll happily maintain freetype and freeimage
<Groogy>
also alright so 's' does count as valid constant value for a enum it seems, BUT not for a macro
<Papierkorb>
Yah the next architecture overhaul will make it much more flexible, so it should be able to cope with pure C as long it doesn't get too whacky
<Groogy>
I am feeling like just manually calculating what each encoding value will be and set it manually <_<
<Groogy>
becaus this is dumb
<Papierkorb>
Lul you should be able to use the clang/bindgen tool for that *cough*
<Groogy>
it's a macro to define enum values though?
<Papierkorb>
Well, it'll give you a JSON document containing the enum constants with values, so close enough
<Groogy>
ah how does it work?
<Papierkorb>
I ask clang really nice to give me those
<Papierkorb>
Which should work for your case too, otherwise it wouldn't be valid C code
<Groogy>
oh you mean bindgen will automatically find out what the enum value here would be?
<Papierkorb>
Yes
<Groogy>
oh please sweet Odin yes <3
<Papierkorb>
Try this $ clang/bindgen -e NameOfEnumHere /path/to/header.h
<Papierkorb>
Pipe that through `jq .` if you have it for nice formatting
<Groogy>
tons of errors because freetype seem to be safeguarding the header if you don't include things in the right order :/
<Papierkorb>
Do you have a sample program or something?
<Papierkorb>
Oh, not `clang` itself, the `clang/bindgen` (that's a path) tool part of the bindgen project
<Groogy>
oh okay thought you meant clang *or* my bindgen tool
<Papierkorb>
Or if you don't wanna mess with clang, just copy/paste all of the enum 'constants' over in a simple C main() which printf()s all of the values
<Papierkorb>
May be the fastest option if you don't have a bindgen installation handy (or if building it fails)
<Groogy>
yeah doesn't seem to be any arch package for it
<Groogy>
so I'll just do the bruteforce way
andrewzah has joined #crystal-lang
<Groogy>
if anyone ever wonders what those magical enums are....
<Groogy>
FT_ENCODING_MS_SYMBOL=1937337698
<Groogy>
FT_ENCODING_UNICODE=1970170211
andrewzah has quit [Ping timeout: 246 seconds]
<Groogy>
(ノ `Д´)ノ ~┻━┻
rohitpaulk has quit [Ping timeout: 264 seconds]
DeBot has joined #crystal-lang
asterite_ has joined #crystal-lang
asterite has quit [Ping timeout: 240 seconds]
asterite_ is now known as asterite
jhass has quit [Ping timeout: 255 seconds]
jhass has joined #crystal-lang
asterite has quit [Ping timeout: 240 seconds]
DeBot_ has joined #crystal-lang
asterite has joined #crystal-lang
jhass has quit [Ping timeout: 252 seconds]
jhass has joined #crystal-lang
DeBot has quit [Ping timeout: 252 seconds]
andrewzah has joined #crystal-lang
andrewzah has quit [Ping timeout: 240 seconds]
linuksz has quit [Quit: Leaving.]
snsei_ has joined #crystal-lang
snsei_ has quit [Remote host closed the connection]
snsei has quit [Ping timeout: 264 seconds]
snsei has joined #crystal-lang
sp4rrow has quit [Ping timeout: 240 seconds]
<FromGitter>
<sdogruyol> lol
andrewzah has joined #crystal-lang
alex`` has quit [Quit: WeeChat 1.9]
andrewzah has quit [Ping timeout: 240 seconds]
andrewzah has joined #crystal-lang
andrewzah has quit [Ping timeout: 255 seconds]
snsei_ has joined #crystal-lang
snsei_ has quit [Remote host closed the connection]
snsei has quit [Ping timeout: 248 seconds]
<FromGitter>
<straight-shoota> Wow, I just had 4 pages of updated issues in the github repo from the last 5-6 hours - most of them having one (or even more) comment from @asterite . It's great to see so much being done! =)
<crystal-gh>
[crystal] asterite opened pull request #4946: Introduce Crystal::Hasher for computing a `hash` value (master...refactor/hash) https://git.io/v5P0b
<FromGitter>
<molovo> Quick question, is there a simple way to check if a constant exists at compile time? For example, I’m building a library that can accept `Kemal::ParamParser` in one of its overloads, but I don’t want to include kemal as a dependency just for that one overload, I’d rather just exclude it at compile time if `Kemal::ParamParser` is not present.
snsei has quit [Remote host closed the connection]