sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]
<FromGitter>
<raydf> Hi everyone, i need an easy way to convert yaml to json in crystal, any ideas?
<crystal-gh>
[crystal] samueleaton opened pull request #3652: Add button in playground to run formatter (master...feat-playground-formatter) https://git.io/v1gki
<FromGitter>
<samueleaton> The reason I was asking about accessing the crystal formatter API here earlier :smile: #3652
<RX14>
BlaXpirit, I don't think the compiler "actually" calls allocate
<BlaXpirit>
if it doesnt, then why would it crash, regardless
<RX14>
so just try using one new method which allocates, casts, then calls initialize
<RX14>
BlaXpirit, because it would use the instance allocate
<BlaXpirit>
RX14, that kills inheritance like i said
<RX14>
which allocates inly instance_sizeof bytes
<RX14>
then the segfault is in the stor
<RX14>
BlaXpirit, how does it?
<BlaXpirit>
you can't make a different `initialize`
<BlaXpirit>
RX14, you don't understand. if you delete the `allocate` methods, it doesnt crash
<BlaXpirit>
if you're saying they are unused, that would be equivalent to deleting them. so you are incorrect
<RX14>
oh
<RX14>
yeah thats interesting
<RX14>
I think you're just not meant to override allocate
<BlaXpirit>
ooh i forgot to set the type id
<BlaXpirit>
makes no difference
soveran has quit [Remote host closed the connection]
mgarciaisaia has quit [Ping timeout: 265 seconds]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has quit [Ping timeout: 246 seconds]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has quit [Ping timeout: 260 seconds]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has quit [Ping timeout: 258 seconds]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has quit [Ping timeout: 245 seconds]
mgarciaisaia has joined #crystal-lang
optikfluffel has joined #crystal-lang
asdlh has joined #crystal-lang
mgarciaisaia has quit [Ping timeout: 260 seconds]
mgarciaisaia1 has joined #crystal-lang
akwiatkowski has quit [Ping timeout: 264 seconds]
<FromGitter>
<yxhuvud> If you are not meant to override the allocate method, then perhaps there should be a variant alike what is created by the struct or class keywords that allows you to define it by yourself and do manual memory management.
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<akwiatkowski>
is there a point how markdown parser is written now? it looks like it byte by byte, not to try find elements from smallest one to all?
<FromGitter>
<firejox> I think RAII is a way for manual management. Allocate memory when struct is created, and free memory when struct is destroyed.
<BlaXpirit>
firejox, what's that about
<BlaXpirit>
if you mean about the earlier conversation, the way you're describing is the most strightforward way, but every operation has to go through 2 pointers
<RX14>
it's been abandoned since february so no, it won't work
<FromGitter>
<asterite> @BlaXpirit it seems allocate does need to set the type id... and getting that seems to be kind of impossible right now
<RX14>
string get it
<BlaXpirit>
oh? I thought just using crystal_type_id would work (I mean it compiled, anyway)
<RX14>
yeah, String uses `"".crystal_type_id`
gloscombe has quit [Remote host closed the connection]
<FromGitter>
<asterite> Yes, the problem is how to get an instance of AA without creating it... and whenever you use `.as(AA)` it will make it an `AA+`, and to get the type id from a virtual type we use the first element behind the pointer
<FromGitter>
<asterite> but that code fails as soon as you put a WeakRef inside a union (which you normally wouldn't do, but it shouldn't crash)
<BlaXpirit>
so basically anyone who subclasses WeakRef makes the program crash...
<FromGitter>
<asterite> I guess so
<FromGitter>
<asterite> Maybe allocate should invoke allocate_memory that returns a pointer to the memory, because that's what you basically want to override
<FromGitter>
<asterite> At least WeakRef wants to override that, and it seems you too
<BlaXpirit>
yes
<BlaXpirit>
what i want is to add a constant amount of memory to my instances. which i can do with StaticArray, but if I do inheritance, I need to extend that memory somehow so I add another StaticArray but what if someone adds a variable in between
<BlaXpirit>
that's the current state of my lib, would be nice to have a safer alternative and always put the memory region after whatever the user may have defined
<FromGitter>
<asterite> why do you need that extra memory?
<BlaXpirit>
asterite, it's the good old bindings to SFML. the memory is for C++ objects to reside in
<BlaXpirit>
i finally want a proper solution to this, then i can try to popularize this approach and get more performant bindings
<RX14>
you want to avoid a double-dereference?
<BlaXpirit>
yes
<RX14>
have you actually benchmarked it to see if it's worth the effort?
<BlaXpirit>
no :p
<BlaXpirit>
hm maybe i did
<BlaXpirit>
i remember something vaguely, i guess i just compared simple examples on old bindings and new bindings
<BlaXpirit>
was like 30% faster or something but not necessarily due to avoiding double dereference
mussela has quit [Quit: Page closed]
asdlh has quit [Quit: Leaving]
<crystal-gh>
[crystal] Sija opened pull request #3658: Implement class_* accessor macros (master...class-accessor-macros) https://git.io/v12h8
Cyrus has joined #crystal-lang
djbell has joined #crystal-lang
<djbell>
is this a known bug? `icr(0.20.1) > false ? : 7 : : 9
<djbell>
=> 9
fcmod has quit [Ping timeout: 260 seconds]
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]