Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 03:41
    Blacksmoke16 edited #12393
  • 01:59
    Blacksmoke16 edited #12393
  • 01:57
    Blacksmoke16 edited #12393
  • 01:57
    Blacksmoke16 edited #12393
  • 01:49
    Blacksmoke16 labeled #12393
  • 01:49
    Blacksmoke16 labeled #12393
  • 01:49
    Blacksmoke16 labeled #12393
  • 01:49
    Blacksmoke16 opened #12393
  • 01:09
    phil294 edited #12392
  • 01:08
    phil294 edited #12392
  • 01:07
    phil294 edited #12392
  • 01:00
    phil294 edited #12392
  • 00:58
    phil294 edited #12392
  • 00:58
    phil294 edited #12392
  • 00:57
    phil294 edited #12392
  • 00:56
    phil294 edited #12392
  • 00:55
    phil294 labeled #12392
  • 00:55
    phil294 opened #12392
  • Aug 15 23:55
    HertzDevil labeled #12391
  • Aug 15 23:55
    HertzDevil labeled #12391
Ali Naqvi
@naqvis
and structs are passed by value, so any modification to value type doesn't impact the original object. Unless you are dealing with objects inside your struct
y8
@y8
They are passed by value, yes, but they are mutable. You can change them in the local scope and you can pass mutated version down the pipe. I would like to have explicit immutability to prevent any changes to instances once initialisation is complete. On that matter, I like the way swift manages mutability.
George Dietrich
@Blacksmoke16
just done define any setters then
dont*
y8
@y8
You still can accidentally mutate state in its own scope. It's "kinda immutable" and won't be caught by compiler. that's the beauty of explicit immutability
y8
@y8
Also, am I missing somethgin here? https://play.crystal-lang.org/#/r/cpxh
Why it tries to match against SecondOne+ instead of ValidUnion?
y8
@y8
Huh. But action return type is exactly VaildUnion. Why virtual type here?
George Dietrich
@Blacksmoke16
the union is reduced into SecondOne+ virtual type
is somewhat of a gotcha when it comes to unions like this
the docs mention that in that link
y8
@y8
Hum. So it shouldn't be reduce it to abstract class, right?
George Dietrich
@Blacksmoke16

dont think so?

The compiler will always do this for classes and structs under the same hierarchy

using a module as an interface could work better in this context
y8
@y8
Uh. It's top level class frombindata shard. BinData itself is an abstract class. I have multiple parses inherited from it. And one of them got it's own ancestors. I want to specialize some methods by that one class with it's own ancestors, but crystal squashing it to BinData+ with quazillion other classes :(
George Dietrich
@Blacksmoke16
still, could you use modules for those specialization?
maybe not, not real familiar with your code, but thats an idea
y8
@y8
If I'll mix module to all that classes, I'll be able to specialize by module, not inheritance hierarchy?
George Dietrich
@Blacksmoke16
you'd be able to type something based on the module yea
which could play well given abstract methods
y8
@y8
Didn't work in my case, so i slapped it with big trout case statement
y8
@y8
Case switch can't be used inside macro statements ({% case %})?
George Dietrich
@Blacksmoke16
Nope
y8
@y8

Uh. I don't really get how to work around virtual types. I would love to have annotation to disable virtual typing for specific hierarchies.

My case is: https://play.crystal-lang.org/#/r/cq9m

I'm decoding wasm assembly and it got two formats: text and binary.

Naturally, I want to fully decouple instructions from their encodings, because instructions responsible for code execution. They have different execution specialisations and some of instructions have immediate values.

My idea is to have mapping of opcodes/names to instruction types. And parse instructions with immediate values with parse_data overloaded with matching signature. This is preferable solution, because their binary assembly have prefixed opcodes so I can further nest parsing withdef parse_data(type : Instruction::Prefixed.class)

What are my options there?

Im okay with generating stuff with macros. But only option that I see at the moment is to generate giant case switch
Scott
@dscottboggs:matrix.org
[m]
is there really no way to get a reference to a value type? I tried to create an Atomic(Time?) and it says that you Can only create Atomic with primitive integer types, reference types or nilable reference types, not (Time | Nil). So I says to myself "okay, no problem, Atomic(Pointer(Time?)). Nope, you can't have an Atomic(Pointer) either, Pointer is also a Value. I guess in my case I can use UInt64 timestamps but it seems like there should be some way to box up a Value in a Reference...
y8
@y8
Not really what I imagined, but it is at least something: https://play.crystal-lang.org/#/r/cqaz
y8
@y8

With some kind of parsing generalization: https://play.crystal-lang.org/#/r/cqb2

Doesn't feel right though

y8
@y8
@dscottboggs:matrix.org like this, maybe? https://play.crystal-lang.org/#/r/cqbq
Scott
@dscottboggs:matrix.org
[m]
Yup
y8
@y8
Module validation failed: Function return type does not match operand type of return inst!. I'm breaking crystal all day long. This is third time I've crashed compiler :D
Ary Borenszweig
@asterite
If you inherit generic types and continue inheriting types, things break. It's been known for a while. Until that's fixed you probably want to avoid doing those things :-)
y8
@y8
@asterite I've surrended to virtual types and ended up with humongous case switch to parse things. But I'm still curious what's the secret sauce of cooking with virtual types? As you can see I love inheriting things! :D Virtual types defo will hunt me when I'll be dealing with vm implementation
Lairan
@alex-lairan

Hey!
What ORM do you use today with crystal?

For SQL queries

George Dietrich
@Blacksmoke16
if you're not doing anything super complex, the driver + DB::Serializable works pretty well
28 replies
From IRC (bridge bot)
@FromIRC
<waleee> which lsp is considered the best these days for crystal? I was aware of 2 when I did some experiments in crystal about 2 years ago
George Dietrich
@Blacksmoke16
Afaik crystalline or something like that
From IRC (bridge bot)
@FromIRC
<waleee> Back then it looked to have a wider scope of features compared to the one that's in the crystal-lang github org
George Dietrich
@Blacksmoke16
Afaik there isn't one in that repo
From IRC (bridge bot)
@FromIRC
<waleee> yeah, it was not there now
George Dietrich
@Blacksmoke16
Mhm
From IRC (bridge bot)
@FromIRC
<waleee> wow, the readme for crystalline wasn't joking about the long compile time
George Dietrich
@Blacksmoke16
Dunno, never used it
From IRC (bridge bot)
@FromIRC
<waleee> about 5 minutes on my not-super-powered laptop
<waleee> ... and now it crashed on something
<waleee> oh. It went for the wrong llvm (13)
From IRC (bridge bot)
@FromIRC
<riza> now you have me curious how long it'll take the m1
<waleee> wasn't it mostly various codec related stuff that's much faster?