!EtGqjSRNQoJCbpCJSF:matrix.org

Nim programming language

8278 Members
Official Matrix channel for the Nim programming language. This channel is bridged with our main Discord and Gitter channels.94 Servers

Load older messages


SenderMessageTime
3 Oct 2024
@_discord_1192207018057007247:t2bot.ioswrge is this fine or not ? 21:11:42
@elegantbeef:matrix.orgElegantbeef It's fine it just allocates 2^16 bits in static memory. What is RecvEvent? 21:12:15
@elegantbeef:matrix.orgElegantbeefThe issue is when you do store the sets in a field21:12:27
@_discord_1192207018057007247:t2bot.ioswrge type of event i receive over a socket, i probably should name that RecvKind tho 21:14:00
@elegantbeef:matrix.orgElegantbeefI mean what are it's values21:14:10
@_discord_288750616510201856:t2bot.iodemotomohiro sizeof(set[int8]) == 32
sizeof(set[EnumWith8element]) == 1
21:15:41
@_discord_1192207018057007247:t2bot.ioswrge @_discord_1196075973871943741:t2bot.io
    RecvEvent* {.pure.} = enum
        RecvDispatchedEvent = 0,           
        RecvClientHeartbeat = 1,
        RecvClientDisconnect = 2,
        RecvNeedReconnect = 4,          
        RecvError = 8,           
        RecvUpdate = 12      
21:18:07
@_discord_1192207018057007247:t2bot.ioswrge huh... 21:19:02
@elegantbeef:matrix.orgElegantbeef set[int8] takes 256 bits 21:19:18
@elegantbeef:matrix.orgElegantbeef256/8 = ....21:19:23
@elegantbeef:matrix.orgElegantbeefwhich is why the cast did not work21:19:31
@_discord_1192207018057007247:t2bot.ioswrge yeah 21:19:37
@_discord_1192207018057007247:t2bot.ioswrge i feel a lil stupid lol 21:19:47
@elegantbeef:matrix.orgElegantbeef The fact RecvEvent does not just do 1, 2, 4, 8, 16 is an affront to sanity 21:20:33
@_discord_288750616510201856:t2bot.iodemotomohiro EnumWith8element in that code is supposed to be simple enum, but your RecvEvent is holey enum. 21:20:44
@elegantbeef:matrix.orgElegantbeefYour method is pretty much the lowest CPU runtime one can do 😄21:21:11
@_discord_1192207018057007247:t2bot.ioswrge whoosp lol 21:21:23
@elegantbeef:matrix.orgElegantbeefIt's O(1) but takes up 2^16 bits21:21:27
@_discord_1192207018057007247:t2bot.ioswrge I don't really understand the holey enum thing 21:22:16
@_discord_288750616510201856:t2bot.iodemotomohiro
echo sizeof(set[int8])

type
  En = enum
    A,
    B,
    C,
    D,
    E,
    F,
    G,
    H
  RecvEvent* {.pure.} = enum
    RecvDispatchedEvent = 0,           
    RecvClientHeartbeat = 1,
    RecvClientDisconnect = 2,
    RecvNeedReconnect = 4,          
    RecvError = 8,           
    RecvUpdate = 12  

echo sizeof(set[En])
echo sizeof(set[RecvEvent])


Result:
32
1
2
21:22:16
@_discord_1192207018057007247:t2bot.ioswrge oh ok 21:22:32
@_discord_1192207018057007247:t2bot.ioswrge so im wasting space 21:22:38
@_discord_288750616510201856:t2bot.iodemotomohiro If enum members have discontiguous numbers, it is a holey enum. 21:23:34
@_discord_1192207018057007247:t2bot.ioswrge yeah i just didnt understand at first you meant i was taking up more space 21:24:20
@_discord_1192207018057007247:t2bot.ioswrge than necessary 21:24:26
@_discord_1192207018057007247:t2bot.ioswrge i'll keep that in mind, im not bothered too much by this tho 21:25:55
@_discord_1192207018057007247:t2bot.ioswrge ty everyone ! 21:26:11
@_discord_761532440669061120:t2bot.ioholy5300 joined the room.22:46:49
4 Oct 2024
@_discord_1265364872804302992:t2bot.iolfghs joined the room.01:55:49
@scorngyworngy:matrix.orgscorngyworngy joined the room.03:12:51

There are no newer messages yet.


Back to Room ListRoom Version: