#🪅-progaming

1 messages · Page 44 of 1

dense sand
#

sonarqube is screaming at me

placid cape
#

xdddd

dense sand
#

since they hard forked

spark tiger
#

are recursive structs considered a bad practice? not sure what would be the better approach for a file tree
(ignore the lifetimes, i have nfi what these are, just used 'a so rust-analyzer stfu

dense sand
#

i mean how else do you want to do this

fleet cedar
#

Nah they're fine, though in this instance a Vec<String> would do the job better

spark tiger
dense sand
#

i really want to rewrite my jvm parser from ground up

royal nymph
dense sand
#

fuck it im doing it lol

spark tiger
fleet cedar
dense sand
#

is there anyone knowledged in avr libc? i know it has malloc/free fucntions, but do they work as i expect them to do? or do they behave differently?

ivory heath
spark tiger
royal nymph
#

inconsistent

fleet cedar
spark tiger
spark tiger
royal nymph
#

this makes no sense

#

why are you differentiating between folders and files like this instead of using the same struct

unkempt shuttle
#

rust???

#

hello

royal nymph
#

also you should name it Directory instead of Folder

spark tiger
#

i thought someone was going to tell me so isob

#

i'm a proud windows user

#

ig i can just do it like uhhh so?

struct Entry<'a> {
    name: String,
    bytes: &'a [u8],
    path: Vec<String>,
}
royal nymph
unkempt shuttle
royal nymph
#

storing a Vec as path is unintuitive

unkempt shuttle
#

(you could also use a PathBuf)

spark tiger
#

i forgor

unkempt shuttle
#

so now it's..?

#

why can't you just store the entries as names and paths and then load them as needed

#

i have no idea what's going on to be fair but that's what i would do PensiveCore

spark tiger
ivory heath
# spark tiger not sure what any of that means tbh lol

It’s not applicable here as far as I can tell but when you have a struct that contains a list of structs (generally) each sub struct will be its own memory allocation and will fragment along with other allocations the memory allocated to the process artificially boosting the memory usage.
If you want to read all the data sequentially instead of storing just a list for each property you must do 2 pointer dereferences and due to not being linear the compiler cannot make any SIMD optimizations.

Here neither apply. Just logically it’s weird

unkempt shuttle
#

"the begin address and size"?

#

i'm assuming you mean the beginning address and the filesize?

spark tiger
# unkempt shuttle i'm assuming you mean the beginning address and the filesize?

yeah. i can send the explanation from the prompt i asked chatgpt (i was so lost i had to ask chatgpt how to reverse engineer the file format)

I’m reverse engineering a proprietary
binary file format used for storing game assets. Well, there are actually three different files:

  1. bigfile.bfn — used for storing file names and file tree. The structure is the following: first there are 4 bytes (u32) that represent the size of the folder’s name. Then there is the string - the folder’s name - that has that many amount characters as the u32 we just got. After that we have another 4 bytes (u32) that represent the amount of files in the folder, let’s call it files_len. After that there are files_len amount of the following structure: 4 bytes (u32) that amount of bytes that represent a utf-8 file name. Then there’re another 4 bytes (u32) — the amount of subfolders in the folder we’re in. And the cycle repeats
  2. bigfile.bfdata — the biggest size-wise file out of these, which as could be guessed contains the binary data for the files from the previous file
  3. bigfile.bfdb — the least researched file which, it seems, should link the file names with the binary data they contain. The issue is that I haven’t managed to reverse engineering it yet. I decided to pick one file from bigfile.bfn and found the address and size of the binary data it has in bigfile.bfdata. The way I could confirm that this file name exactly links to this data is by using binwalk. It shows which files are contained in the file’s binary by searching for signatures and magic bytes. That way I could find all the PNGs and I decided to take the last one, thinking that the order of files in bigfile.bfdata and bigfile.bfn. I was correct. That way I had the matching file name and the data it represents. Searching for the address of the file’s name from bigfile.bfn didn’t get any results in bigfile.bfdb. But searching for little-endian byte representation of the address of the file data was successful and just 8 bytes before it I found LE-bytes that represent the size of the file data.
unkempt shuttle
spark tiger
#

i was like at the final step of finishing reversing this file format but i couldn't find the way to link file 1 and file 3

fleet cedar
#

Things with big fancy trees like compilers often use fancier things than boxes, but for casual stuff it's fine

spark tiger
#

also i wonder what would be better:

  1. store the beginner address of the file data and the filesize in the entry struct
  2. store the beginner address of the file data and the final address in the entry struct
  3. don't store these in the entry struct, instead read it from file 2 when extracting the files from the 'archive'
unkempt shuttle
#

so you're reading out of the file into your own structs and not from an file system

spark tiger
#

yes, these files/entries do not actually exist on the uh machine

unkempt shuttle
#

okay

#

hmm

spark tiger
#

i have an idea - what if i just look at the implementations of already existing archive managers made in rust

scarlet tendon
#
(async () => {
    // Get the token using Vencord
    const tokenData = Vencord.Webpack.findByProps("token");
    const token = tokenData?.token;

    if (!token) {
        console.error("Token not found.");
        return;
    }

    console.log("Using token:", token);

    // Set headers 
    const headers = {
        "Authorization": `Bearer ${token}`,
        "Content-Type": "application/json",
    };

    // Make the GET request to the Discord API
    const response = await fetch("https://discord.com/api/v9/users/@me/relationships", { headers });

    // Handle the response
    if (response.ok) {
        const friends = await response.json();
        
        // Filter real friends (type 1 = real friends)
        const realFriends = friends.filter(f => f.type === 1);

        console.log(`You' have ${realFriends.length} friends!`);
    } else {
        // Log full response for debugging
        const responseText = await response.text();
        console.error(`Failed to fetch friends: ${response.status} - ${responseText}`);
    }
})();

i wrote this for #📜-js-snippets but i cant quite get it to send my friends i have

#

I have a valid token and i have a python equaivlent that fully works

spark tiger
#

i don’t have much experience with this but i don’t really think you’re supposed to manually write the headers, extract the token and send the request that way. i’m pretty sure there are helper methods inside either vencord or discord that do all that stuff for you

scarlet tendon
#

Hmm wdym ? do you know of these helper methods?

spark tiger
#

from reading a few snippets i assume it's this

#

ofc replace the body with the needed endpoint

spark tiger
scarlet tendon
#

Got it

#
(async () => {

    // Use Vencord to fetch the relationships (friends list)
    const response = await Vencord.Webpack.findByProps("getRelationships").getRelationships(); // Using Vencord's helper function

    // Check if the response is an object and contains the friends list
    if (response && typeof response === 'object') {
        // Count the number of real friends (type 1)
        const realFriendsCount = Object.values(response).filter(f => f === 1).length;
        console.log(`You have ${realFriendsCount} friends!`);
    }

})();

dense sand
fallen nebula
#

Here's a valid reason to be scared

dense sand
balmy lintel
#

doing raw http requests should probably be a last resort

void leaf
#

Damn you cant nest pseudo-elements

dense sand
daring kite
# scarlet tendon Y

hes just chatting sh*t tbh, this aint raw, its using fetch lmfao i dont think he knows code

keen spoke
daring kite
#

but yk better

dense sand
#

isnt this bs?

#

or i just cant read

#

calculus people assemble

keen spoke
jade stone
jade stone
spark tiger
#

tfw rust’s from_ne_bytes is just transmute wires

austere anchor
#

yk

spark tiger
austere anchor
spark tiger
#

?

spark tiger
#

if cfg!(target_endian = "big")
read_be_u32()
else
read_le_u32()

austere anchor
#

blehh too much of a hassle

#

safety ensured anyways because it's enforced by type system

dense sand
#

no <endian.h>?

#

wow

#

bad language fr

#

(the header file is totally not gnu specialty)

austere anchor
spark tiger
#

oh wait no

dense sand
spark tiger
#

or yes

austere anchor
# dense sand poo language

I love not having to copy paste all of my function signatures to header files for it to be able to be used elsewhere

austere anchor
dense sand
#

then you implement it inside C file

#

its not that hard

#

also, you can just directly define it inside .h

austere anchor
austere anchor
#

I'm like

#

"oh yeah I should separate this out"

#

then I have to copy paste to headers

#

annoying

dense sand
#

just use extern bro

austere anchor
#

mid

fleet cedar
#

Wouldn't surprise me if part of the reason for using transmute rather than bit stuff is that it makes it easier to generate the impl for all types with one macro

pearl stagBOT
#

to_bytes.rs: Lines 94-100

fn from_ne_bytes(bytes: Self::Bytes) -> Self {
    // Safety: transmuting between vectors is safe
    unsafe {
        #![allow(clippy::useless_transmute)]
        core::mem::transmute(bytes)
    }
}
spark tiger
#

i have a crazy idea

#

what if i try to implement my parser in zig instead of rust blobcatcozy

#

zig seems surpassingly good for doing these kinds of things at first glance

buoyant sparrow
#

Hi sorry what do you think? Would you like to try this, like we do with the filters for voices but to change the sound of the headset, for example, we would have a surround button, a bass boost button, a rock button... etc. all with a menu on the headset icon, so nothing to do with it and it would be a full plugin because it is not integrated as standard.

dense sand
#

i think no

#

Im thinking miku miku oo ii oo

formal belfry
#

@woven mesa wondering how i should document modifiers on ddbkit docs in a way that isnt like a wall of text and unreadable

#

I tried tables but uhh..

#

yeah

woven mesa
formal belfry
#

idk

woven mesa
#

no the joke is i wrote a wall of text

formal belfry
#

I am thinking i might just hint at modifiers' existence via example codeblocks which i am already doing and i think it might work fine

#

im not sure if people will try to rely on xcode autocomplete or not because some might ignore that lol

#

I would heavily prefer to just not document them because of how self explanatory most of them are but i don't know..

woven mesa
#

idk either

#

its difficult

formal belfry
#

I wish ddbkit server wasn't so dead so i could ask for input

spark tiger
#

zig experience:

create a variable
code won't compile because of error: local variable is never mutated
make the variable a const
code won't compile because of error: unable to evaluate comptime expression

#

like ??????

#

oh i think i get why that happens

#

why is zig so damn hard

#

like it builds fine

#

i run it

#

and i basically get "it failed, idfk why"

fleet cedar
#

Why is "not mutated" a hard error

#

Smells like golang's unused variable errors

spark tiger
runic sundial
#

Show code

#

Zig is like piss easy compared to Rust

#

Hardly ever gets in my way

runic sundial
#

You must use local variables.

spark tiger
# runic sundial Show code

it's p bad as i know nothing about zig, i just read the features page and sample page, but i was expecting the compiler to help me

const std = @import("std");

pub fn main() !void {
    const file = try std.fs.cwd().openFile("C:\\Program Files (x86)\\Steam\\steamapps\\common\\KarmaZoo\\resources\\cookedData\\bigfile.bfn", .{ .mode = .read_only });
    const reader = file.reader();
    try read(reader);
}

pub fn read(reader: std.fs.File.Reader) !void {
    const folder_len = try reader.readInt(u32, .little);
    var list = try std.ArrayList(u8).initCapacity(std.heap.page_allocator, folder_len);
    defer list.deinit();
    try reader.readAllArrayList(&list, folder_len);
    try std.io.getStdOut().writer().print("{s}\n", .{list.items});
}
#

ig it's something with the list

runic sundial
#

Do you have IntelliJ?

spark tiger
#

i'm using zed but like i do have other jetbrains' ides

runic sundial
#

Or RustRover better if on Windows

spark tiger
runic sundial
#

Yeah.

#

Get that, and the ZigBrains plugin

#

(I am biased as my bestest friend ever made it)

#

This, plus zls

#

zls needs to be version matched with zig

#

I usually just use latest upstream for both

spark tiger
#

i think i'm using tagged version of zig as i didn't figure out how to use nightly

runic sundial
#

You'll prolly need to for zls to work, I think the plugin can help with that

#

I can get on computer in a bit, can u vc or nah?

spark tiger
runic sundial
#

Perfectly valid

spark tiger
#

i can't guarantee that i'll actually start using zig, but if you don't mind it, i'm down to learn something new

runic sundial
#

Alr I got it setup on my Windows install

#

can

#

demonstrate

spark tiger
#

let me quickly connect my headphones

formal belfry
#

i looked in quickCSS for something to hide the nitro emojis on reactions, but i couldn't find anything besides just making the nitro bits less flashy. the problem is that anything below what's hidden doesn't want to render properly, does someone have any ideas?

#

or do i go to theme development for this kinda stuff sorry idk

fleet cedar
#

Cssing lazy-rendered lists usually doesn't work well

formal belfry
#

would i need to do javascript then?

fleet cedar
formal belfry
#

thank youuu

supple whale
#
<script>
const volume = persisted('volume', 0)
$: exponentialVolume = $volume ** 3
</script>

<video bind:volume={exponentialVolume} />

did i ever mention how much i fucking love svelte

#

just for shit like this

valid jetty
#

wtf is that syntax

olive mesa
#

would anyone know or be able to help me make it so i can get notofications on my phone from discord dms while still being online and ac tive on my pc? like no idle delay etc

supple whale
#

its peak

#

compiler level reactivity is peak

#

TLDR updating volume in any way, automagically updates the exponential volume

#

so i can do $volume = 0.05

#

and it becomes 0.000125

#

in the video

#

and persisted just syncs it with storage, so localStorage or idb

#

so i can have peristent variables

valid jetty
#
let volume = use_state(|| 0.0);
let exponential_volume = (*volume).powi(3);

let onloadedmetadata = Callback::from(move |e: Event| {
    if let Some(video) = e.target_dyn_into::<HtmlMediaElement>() {
        video.set_volume(exponential_volume);
    }
});

html! {
    <video onloadedmetadata={onloadedmetadata} />
}
``` xd
supple whale
#

jesus

supple whale
#

case in point:

#

15% of a 5800x3d

#

on a single poor animation

#

this is why you should ONLY ever transition and animate transform and opacity

runic sundial
#

TO ALL WEB DEVS

#

Stop doing this

#

Cheers

balmy lintel
#

horror

spark tiger
#

wakatime has a vdp???

cursive beacon
#

tryna run my multi-purpose discord bot husk

dense sand
#

ok

balmy lintel
supple whale
#

the shit on the side of ur mouse?

runic sundial
#

Browsers have a back button.

supple whale
#

so navigation

runic sundial
#

Like the "go back a page"

#

Yeah

#

Fancy sites break that shit

#

Allll the time

supple whale
#

well yeah

#

thats what SPAs are

supple whale
#

i'm about to loose my shit

#
declare global {
  interface MediaSession {
    setActionHandler: (action: MediaSessionAction | 'enterpictureinpicture', handler: MediaSessionActionHandler | null) => void
  }
}
#

BRUH

#

like why isnt this possible in typescript

#

you cant override already defined types

#

D:

nimble bone
ionic lake
#

what about & {}

supple whale
supple whale
#

you can define new, but not override

#

lib.dom.d.ts takes priority over anything you'll ever do

nimble bone
#

// @ts-ignore

supple whale
#

dogshit language

hoary sluice
supple whale
#

like how the fuck do you force types

#

that are incorrect

placid cape
#

easily: you don't

supple whale
#

clearly

dense sand
#

if you want to force types which are incorrect then youre in a wrong language

supple whale
#

BRUH READ

#

i want to correct types which are incorrect by default

valid jetty
supple whale
dense sand
#

make a patch with bun

supple whale
#

you can only append types to an existing interface

dense sand
valid jetty
supple whale
#

legit what do

dense sand
#

make a patch with bun

supple whale
#

had to do a forced asertion

#

setActionHandler: async (...args) => navigator.mediaSession.setActionHandler(...args as [action: MediaSessionAction, handler: MediaSessionActionHandler | null]),

#

but i dont like it

dense sand
#

i fell in love with makefile

#

its so simple its complex

supple whale
dense sand
#

its the type of code that you write once and then never touch it because it can break the whole build process

supple whale
#

yeah

#

i wanted to add pthreads to that build config

#

gave up after like 3 days of work

spark tiger
#

justfile looks interesting though

dense sand
#

can we add sql transactions to C dynamic memory allocations

supple whale
#

@dense sand did ya see the animation perf i posted above btw?

dense sand
#

yes

dense sand
#

this is crazy though

#

the perf difference

supple whale
#

yeah

#

its going from worst to best case

winged mantle
supple whale
#

esp if you're working with new chrome only apis

winged mantle
#

it would break type safety

supple whale
#

break what now

#

type safety

#

in typescript

#

bro what

winged mantle
#

i mean yeah

supple whale
#

you clearly dont understand what i want to do

#

but that's fine

#
navigator.mediaSession.setActionHandler('enterpictureinpicture', console.log)

is valid code, but the default ts types are invalid

#

and erorr on it

winged mantle
#

in terms of language design i don't think they should add the ability to modify interfaces which are not yours

#

you can just use ts-ignore

#

and i'd argue using browser specific apis is bad

supple whale
#

but for a language where u can do Function.prototype = null

#

its not good design

winged mantle
#

typescript is meant to make things safer...

supple whale
#

no, its meant to add typing to js

#

those are not the same things

winged mantle
supple whale
#

just as related to the conversation

winged mantle
supple whale
#

i have 0 idea how a screenshot of typescript marketing keypoints, relates to the fact that the default types for the language it provides are invalid an cant be fixed in any way

#

without forking the types and maintaining them yourself i guess

hoary sluice
# winged mantle

What is TypeScript? A pile of leaves that makes a shitpile invisible and even easier to step in

winged mantle
#

i assure you this image of david tennant has a profound relation to this topic

dense sand
#

has anyone here worked with java xml validation and custom schemas?

#

im getting this weird error

winged mantle
#

may i ask why you are using xml instead of json

dense sand
#

cause xml fits this better

fleet cedar
#

Xml validation is the third circle of purgatory

dense sand
#

would you use json for designing uis?

winged mantle
#

maybe

fleet cedar
#

I would use whatever the ui library I use does

dense sand
#

it fucking declared there, whats your problem 😭

winged mantle
#

java class name in attribute makes me worry about thiis api design

dense sand
#

i can always make it lowercase

#

thats no problem

#

id just like it to work

winged mantle
#

no i mean the class="org.jaibf.plugin.TestInventory"

dense sand
#

oh thats ok

winged mantle
#

means it's using reflection....

dense sand
#

yes

#

im aware of that

winged mantle
#

and i fear what other things it's doing

dense sand
#

i love refelction

winged mantle
#

it just brings back memories of eclipse plugin dev

dense sand
#

horror

fleet cedar
#

Nasty

#

Go wash your codebase with soap

winged mantle
#

what's the point of duplication

dense sand
#

lmao

#

i just want it to work though 😭

#

xml namespaces work please

fleet cedar
#

Futile

#

I have never in my whole career seen a xml namespace do anything that could be remotely described as "work"

winged mantle
#

if i were to do this, i'd use a library that can just pass the ast of the xml and do everything else myself

dense sand
#

wtf did i just found

#

this is chatgpt answer rewritten into wall of text, rendered as a video published to youtuhbe

balmy lintel
#

ai slop

valid jetty
ornate quiver
dense sand
ornate quiver
#

with reflection is crazy

dense sand
#

How do you expect me to do DI

ornate quiver
#

gu

dense sand
#

?

hoary sluice
#

lmao wtf

placid cape
jade stone
#

does anyone know any good local dns server

i dont want to use pihole to just redirect a few queries

#

@deep mulch zootie

deep mulch
jade stone
#

but i might go witht hat because it has nix support

deep mulch
#

i will give you shock therapy so you will hate nix

jade stone
#

you will never get me to hate nix

deep mulch
#

guhh

winged mantle
#

sorry to interrupt your.. whatever this is

#

i am stuck trying to think of a good system for persistent state in discord commands

deep mulch
#

database

jade stone
#

just update the message whenever the state changes

#

use discord search feature to find the message

winged mantle
#

i am trying to have buttons which remember some context about the command

deep mulch
#

i have no hands

winged mantle
#

i don't want to put the data in the buttons themselves

#

i have a custom TTLMap implementation

#

the data only needs to last a short time and not between restarts so db is pointless i think

#

db is being used for other things blobcatcozy

#

i just wasn't sure about a good way to structure things

#

wasn't sure whether i should do

run(context) {
    context.set_state({ current_page: 0 });
    context.respond({ components: [/* ... */] });
},
component_event(context, id) {
    const state = context.get_state();
}

or

run(context) {
    context.respond({ components: [/* ... */], data: { current_page: 0 } });
},
component_event(context, id, data) {
}
#

context is basically something which implement stuff relating to the context as well as a respond function

#

currently there is a SlashContext and a PrefixContext but i guess i'd need a ComponentContext as component responses work differently...

#

so it wouldn't actually be the same object

#

so maybe the former is a little weird

#

wait

#

better idea

#

just design the api naturally and hopefully the implementation will not be insane

run(context) {
    context.respond({
        content: "Press the button",
        components: [{
            text: "Click me",
            callback: click_context => {
                click_context.ack();
                context.respond("You pressed me");
            }  
        }]
    })
}
#

(do you even need to acknowledge the interaction if you are editing the message anyway)

#

(also i forgot async+await lol)

#

i had an unsane idea for generating button customIDs

#

use URLs

#

moderation/ban?callback-id=0

winged mantle
#

that's cursed and sounds like a bad idea because you might forgot that you're storing the data in a button and accidentally leak something

spark tiger
#

guh why did it suddenly stop working

fallen nebula
keen spoke
fleet cedar
#

PRing is always fine (but be prepared to be ignored for months)

fleet cedar
#

Plugin requests is fir begging without contributing

keen spoke
#

Well usually you first request, then triage then PR

#

according to the contrib guidelines my plugin should be fine, basically discord selects the last sent msg and if you sent a msg for which the server has not sent a response that it was posted yet, discord selects the last sent msg when you use the arrow key, extremly annoying. I want it to select the last sent msg, regardless of the server having replied yet. If it has not at the time of sending the PATCH, it should queue the patch, wait for the server to reply and then send the edit

spark tiger
placid cape
#

oh wait you're the one that made the issue

spark tiger
#

yeah lol

placid cape
#

thanks :D

#

i hate windows

spark tiger
#

or maybe not

placid cape
#

idk but there's a bunch of issues with LSP

spark tiger
#

it's so annoying

#

and for some reason the zed team doesn't really seem to work on a fix despite it being a really major issue

placid cape
#

they're not working on windows

spark tiger
#

sad

placid cape
#

only community works on it

#

that's also why they dont provide builds

spark tiger
#

there've been like 3 or 5 PRs attempting to fix that issue but all of them got closed because "it's not a proper fix"

#

like i'd rather have some fix than most extensions being broken

placid cape
#

yeah

spark tiger
#

and the worst thing is that i'm not really sure like what to blame

#

like is it wasmtime's issue or wasi's issue or zed's issue

placid cape
#

well it makes sense they don't want bad code in their codebase but it's still better than nothing and you can just add comment in the issue

spark tiger
#

i'm not so sure how exactly extensions work in zed, but it seems like it basically tries to execute the commands with wasm paths (prefixed with /) outside wasm runtime or whatever

#

because wasmtime can open /* paths just fine

placid cape
#

💀 amazing idea, let's modify std behaviour

spark tiger
#

that silly bug is stopping me from starting to use wakatime :(

placid cape
#

:(

#

well you can build zed with the patch

spark tiger
#

yeah i can, it's just that i want to have a comfy way of managing it - currently by using scoop

#

i don't really want to like manually add it to path, to apps list, etc.

placid cape
#

well yea understand

#

that's way easier on linux

#

like i have my own packages repository for pkgs that are not on void repos

#

so everything is managed by xbps

spark tiger
#

windows is funni

#

and i'm too uh lazy to get used to linux

placid cape
#

its not that hard

#

the hardest thing is to do it

#

i fully switched to linux like 2 years ago

spark tiger
#

i tried to move to linux (or at least get used to it) a year ago

#

i installed mint and it seemed good for the first two weeks

#

but then i just kinda lost any point in using it

#

so i was just booting in windows

frosty obsidian
astral current
#

then ai to do the prompts

hoary sluice
#

they try to make it easier to migrate from windows by making it look similas to windows and super bloated

#

u need to install arch manually, without install scripts, get a tiling window manager and either delete windows or promise urself not to use it at all for a month or two

winged mantle
#

what the hell

#

my code worked

#

scary...

#

i literally only made one mistake and first time it worked

#

(just forgot to register event handler)

hoary sluice
winged mantle
#

it's interesting how code made by copying and pasting other code works best usually

winged mantle
winged mantle
#

yes

hoary sluice
# winged mantle yes

crazy how i was able to guess that just from the fact that everything worked right away

winged mantle
#

in this case earlier i was using typescript

hoary sluice
winged mantle
#

i was using rust for one thing but not another thing

winged mantle
#

how does v8 "know" not to garbage collect i blobcatcozy

#

does it just keep all variables loaded

#

or do that when there is an eval call

#

(as i believe that's the only function which can see local variables without needing to pass them)

royal nymph
#

using direct eval forces it to make a bunch of assumptions

winged mantle
#

ah

#

makes sense

#

thanks

#

now i can stop being paranoid about a few bytes extra memory usage

hoary sluice
#

@valid jetty why is stdlib qsort only barely faster than random geeksforgeeks merge sort impl

#

with 1 million random numbers between 0 and 1 million

austere anchor
#

works on all data

#

unspecialized

valid jetty
#

yea ^^^^

hoary sluice
#

does it not optimize for ints if it sees ints

valid jetty
#

specialized ones probably have better pivots for the qsort

#

it will always be an int bestie

hoary sluice
#

so unspecialized as in it doesnt specialize for specific ranges of ints?

valid jetty
#

also your input set is not integers lol

hoary sluice
valid jetty
#

you said between 0 and 1

#

that implies a float

#

oh

hoary sluice
#

u cant read i think

valid jetty
#

i love mobile and outside

hoary sluice
#

lmao

hoary sluice
#

can u not define a sorting function for structs

valid jetty
#

you can???

#

that’s the point of the cmp thing in qsort it takes a comparator function

#

but that function still compares ints lol

hoary sluice
hoary sluice
#

i love having bad internet and sending msgs twice

austere anchor
#

it takes in a void*

#

it cannot know it's an int that it's comparing

#

the only thing it does is call the cmp function on 2 elements every turn

valid jetty
#

^^^^

#

i made my own in elle xd

#
fn Array::sort<T>(T[] self) {
    if self.is_empty() || self.len() <= 1 {
        return;
    }

    __internal_qsort(self.elements, 0, self.len() - 1);
}

local fn __internal_qsort<T>(T *array, i32 low, i32 high) {
    if low >= high {
        return;
    }

    T pivot = array[high];
    i32 i = low;

    for i32 j = low; j < high; j += 1 {
        if array[j] < pivot {
            T temp = array[i];
            array[i] = array[j];
            array[j] = temp;
            i += 1;
        }
    }

    T temp = array[i];
    array[i] = array[high];
    array[high] = temp;

    __internal_qsort(array, low, i - 1);
    __internal_qsort(array, i + 1, high);
}
winged mantle
#

looks so good i need to learn elle....

hoary sluice
#

@valid jetty is claude 3.7 neferious

spark tiger
#

i decided to try claude today but i didn't know it's literally fucking 10 free msgs a day or something

#

and unlike on chatgpt there isn't like free model that you can use without any limits

#

and the subscription is even more expensive than chatgpt plus

#

$30 a month

#

i guess i'll just keep using 4o(-mini)

hoary sluice
#

might buy claude again

hoary sluice
spark tiger
#

also what kinda annoys me a bit is the lack of any markdown in claude

#

i'm so used to it in chatgpt

#

it's kinda hard to read text in claude

native spruce
#

@woven mesa you use uikit for ipod right?

#

I was wondering if you use a uikit navigation controller as well

#

trying to use any sort of collection view causes my swiftui navigationview to act strange

#

holy shit nevermind

#

.ignoresSafeArea(.all)

#

why does that work even

#

okay

native spruce
#

why the fuck does a scrollview act so weird in swiftui holy shit

valid jetty
#

i finally added allocator switching to elle xd

woven mesa
#

sowwy my mom had my phone

#

she was playing pokemon go

native spruce
#

its okay

royal nymph
#

it's easy to do

#

just need to tell the ai in the prompt that it can use markdown and then well render it

spark tiger
#

sadly this won't fix me being broke as hell

royal nymph
#

does it not have a free tier

spark tiger
#

either i did something wrong or the free tier is only like 10 messages a day or every 6 hours

royal nymph
#

ohhh

worldly sigil
spark tiger
#

amazing espainespainespain

placid cape
#

In zed you have 10$/month for free

spark tiger
#

i mostly use chatgpt for some coding stuff at school from my phone

#

i'm just often very bored there so i just read some code and ask chatgpt to explain some stuff for me

#

wtf does that mean

still jolt
#

it means that the function is defined here ​​​​​​​​​​​​​

#

(you probably have an error or warn on a different line and it's misinterpreting extra info about it as something it should display)

spark tiger
#

yeah looks like that was it

#

yippie it compiled

spark tiger
#

that looks so ugly, but i hope it's fine

winged mantle
#

why is type not narrowing here...

#

(trying to make type checking stricter because i keep missing bugs blobcatcozy)

woven mesa
#

@spark tiger hiii

spark tiger
woven mesa
#

eepy

#

hbu

spark tiger
#

me too

austere anchor
#

there's no guarantee that emoji.name is a key of icons as far as typescript is concerned

winged mantle
#

which is meant to happen

#

i guess it only narrows the value on the right side

#

not the left

austere anchor
#

that's confusing

#

does it not check at runtime ??

woven mesa
#

@austere anchor gonna work on more ipod

winged mantle
#

if typescript was to narrow the type, the type of s would be keyof typeof a, when there are actually more keys which are just not required by the type

austere anchor
austere anchor
#

"there are actually more keys which are just not required by the type"

valid jetty
#

@placid cape you can finally switch allocators lol

#

(its logged after #free because i wanted to show that its just a stub for the gc and arena as you dont free like that)

#

you can also do --nogc to use arenas instead of a gc as the default allocator

placid cape
#

noice

#

i haven't worked on blom for few days bcs i don't have any time 😭

valid jetty
#

i dont either really but i had just a little bit of time so i did it

winged mantle
woven mesa
#

Warning once only: UITableView was told to layout its visible cells and other contents without being in the view hierarchy (the table view or one of its superviews has not been added to a window). This may cause bugs by forcing views inside the table view to load and perform layout without accurate information (e.g. table view bounds, trait collection, layout margins, safe area insets, etc), and will also cause unnecessary performance overhead due to extra layout passes. Make a symbolic breakpoint at UITableViewAlertForLayoutOutsideViewHierarchy to catch this in the debugger and see what caused this to occur, so you can avoid this action altogether if possible, or defer it until the table view has been added to a window. Table view: <FLEXTableView: 0x115d26a00; baseClass = UITableView; frame = (0 0; 390 844); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x302513960>; backgroundColor = <UIDynamicSystemColor: 0x3030ae280; name = tableBackgroundColor>; layer = <CALayer: 0x302b64a00>; contentOffset: {0, 0}; contentSize: {390, 0}; adjustedContentInset: {0, 0, 0, 0}; dataSource: <FLEXHierarchyTableViewController: 0x11ec4b700>>

#

ok thanks bro

austere anchor
# winged mantle took several attempts lol

huh, then next i shall ask why const c: typeof a = b is even valid given that b is clearly not typeof a unless it somehow does some restriction thing such that you can only access the keys that a has

#

also audio explanation fire

winged mantle
#

i thought it would be easier than typing essay

#

but i paused

austere anchor
winged mantle
austere anchor
#

why is access like that even allowed

#

surely you should be forced to have typeof b to access b's keys

#

(i am coming from rust's typesystem for context)

winged mantle
#

ah

#

a very different system

austere anchor
#

no easy implicit casts unlike *script

winged mantle
winged mantle
valid jetty
austere anchor
valid jetty
austere anchor
#

if let Some(x) = y

winged mantle
#

WHAT

#

my life is a lie

austere anchor
#

the type system is not completely ass

valid jetty
#

if you do this it lets you

austere anchor
#

it should be marked uhh

#

unsafe

valid jetty
#

and you still get autocomplete so its better than just Record<PropertyKey, any>

valid jetty
winged mantle
#

oh wait

#

of course

austere anchor
valid jetty
winged mantle
#

but that's specific to object literals

woven mesa
#

any

winged mantle
#

const a = {a:"eawewa", yormum:"afwjkwafkwajf"}
const b: { a: string } = a;

#

works

#

(i think)

austere anchor
winged mantle
#

(99.99% sure)

valid jetty
#

yeah i guess

woven mesa
winged mantle
#

my core point was

#

because if you have a type like { a: string } it does allow other keys

#

i forgot this doesn't work if you use the object notation

valid jetty
#

@austere anchor do you love

use std/prelude;
use std/allocators/arena;
use std/allocators/heap;

fn do_stuff<T>(T *allocator) {
    #set_allocator(allocator);
    $dbg(#env.allocator.kind);
    ptr := #alloc(i32, 5);
    #free(ptr);
    $dbg(ptr);
}

fn main() {
    $println("By default:");
    $dbg(#env.allocator.kind);
    $println("-".repeat(40));
    do_stuff(HeapAllocator::new());
    $println("-".repeat(40));
    do_stuff(ArenaAllocator::new());
    $println("-".repeat(40));
    $println("Default allocator:");
    do_stuff(#env.default_allocator);
}
winged mantle
#

but if you implement an interface in a class for e.g. yo ucan also add loads of _properties to keep internal state like i do

valid jetty
#

you can finally have temporary buffers and stuff

winged mantle
austere anchor
woven mesa
#

recording what tho

valid jetty
#

before it was just GC lol

austere anchor
woven mesa
#

fr

valid jetty
#

if you wanted to change it before you had to change the allocator at the time of compiling the compiler

austere anchor
#

@valid jetty does elle support no_std for embedded

valid jetty
#

ellec foo.le --noalloc --nosm --nofmt --nostd

#

disables all

#

actually you dont need --nogc

#

if --noalloc is there it wont make gc anyway

#

although the issue is that it compiles to qbe lol

#

so youre not gonna be running it on embedded anyway

austere anchor
#

does qbe need an os or sumn?

valid jetty
#

no just the targets

#

i guess rv64

austere anchor
#

is arm64 not for embedded?

valid jetty
#

what i meant is like

#

youre not gonna be able to compile for sh3eb-elf

#

or whatever

woven mesa
#

30 warns

#

so good

austere anchor
valid jetty
#

qbe doesnt have armv7 either lol

austere anchor
#

that should probably be added

valid jetty
#

probably hard

austere anchor
#

oh it has zero suport for 32-bit

#

nevermind then

valid jetty
#

so many

valid jetty
austere anchor
#

@valid jetty elle on LLVM

valid jetty
#

maybe in the distant future

#

it shouldnt be that hard tbh

#

just time consuming

#

consuming time i dont have

woven mesa
#

@austere anchor tiny spikes yippee

austere anchor
#

troller

valid jetty
#

i wonder if i can make more zero cost abstractions like this

austere anchor
valid jetty
#

lmao

#

meanwhile i decided io::println was too long and made aliases so you can do $println

#

among others

austere anchor
#

java went the other way and decided nothing is global

valid jetty
#

im about to chat spam

#

so apologies

#

but is this a good explanation

#

is there anything else i should have

#

Allocators

Elle has a moderately complicated allocator system. Here's how it works:

  • By default:
    • garbage collection
  • Using the --nogc flag at compilation:
    • arena-based allocation

Changing the allocator:

#set_allocator(MyAllocator::new());

Resetting to the default allocator:

#set_allocator(#env.default_allocator);

Make sure you don't forget to free any memory leftover when switching allocator! #set_allocator does not call the free_self method on the previous allocator when switching allocator, to allow for programs designed like this:

fn main() {
    arena := ArenaAllocator::new();
    #set_allocator(arena);
    x := [1, 2, 3]; // x is allocated through the ArenaAllocator
    #set_allocator(#env.default_allocator);
    $println(x); // allocates via default allocator
    #set_allocator(arena);
    #env.allocator.free_self(); // frees the arenas
    #set_allocator(#env.default_allocator); // go back to default allocator
}

What should an allocator have defined on it?

  • Allocators should have the following methods defined on them:
    • MyAllocator::new() (preferrably allocating the allocator structure itself via mem::malloc)
    • MyAllocator::alloc(MyAllocator *self, i32 size) -> void * (size in bytes to allocate, should return void *)
    • MyAllocator::realloc(MyAllocator *self, void *ptr, i32 new_size) -> void * (new_size in bytes. should return void *)
    • MyAllocator::free(MyAllocator *self, void *ptr) (may be omitted if permitted by the allocation model, will become noop)
    • MyAllocator::free_self(MyAllocator *self) (destructor for the allocator itself, NOT objects created by it)

Disabling allocation altogether:

  • You can pass the --noalloc flag during compilation. Keep in mind that, while this will remove allocators, you won't be able to use any of the standard library, as all of it depends on these allocators. This goes well with the --nostd flag.
#

its all a trick which is funny imo

#

the arbitrary allocator is a struct that has fields for the underlying allocator and function pointers to its methods

#

#set_allocator gets the type of that expression passed in, ensures its a struct or struct *, then sets the fields of the arbitrary allocator to the function pointers of the allocator you specify, or if it cant find a method it sets it to a noop method that returns nil

#

probably better ways to do this

fleet cedar
#

#set_allocator(MyAllocator::new()); should return the previous allocator so that you can nest them hierarchically

valid jetty
#

that

#

is a bit cursed but i like it

#

the issue is that you lose access to the information about the allocator at compile time when you do #set_allocator

#

as it works with pure void *

#

so if it returned prev it would need to return a bunch of void * together or something idk

#

#env.allocator.kind is set to a string literal but that makes it runtime based

runic sundial
#

Just use, Zig?

#

Part of the standard library over here

valid jetty
#

the point is that im making my own language lol

runic sundial
#

LLVM front end?

valid jetty
#

nope qbe

runic sundial
#

Wharg

valid jetty
runic sundial
#

What backends does qbe even have

valid jetty
#

@austere anchor good idea to bring $scoped back? idk how i feel about it

runic sundial
#

Where SPIR-V

valid jetty
#

so you can do

fn main() {
    x := 39;
    $scoped(ArenaAllocator::new(), fn(i32 *x) {
        arr := [*x, *x * 2, *x * 3];
        $println(arr);
    }, &x);
}
``` and this time it *will* call `ArbitraryAllocator.free_self` before setting to the previous allocator
runic sundial
#

Also kinda strange that free_self doesn't free associated allocations

valid jetty
#

it does

#

it frees the entire structure which includes allocations created by it

runic sundial
valid jetty
#

as in, if you alloc something, dont use free_self to free it because that frees the entire structure

runic sundial
#

What's wrong with a model doing that?

#

It's easier in some contexts

#

Create allocator, do a bunch of dumb stuff, free the whole allocator

valid jetty
#

nothing is wrong i just said that free_self specifically frees the whole allocator including all of its allocations instead of just an object created by the allocator

#

its important to make that disctinction

#

because you might use it thinking it frees an object

#

idk

valid jetty
#

this

fn main() {
    arena := ArenaAllocator::new();
    #set_allocator(arena);
    x := [1, 2, 3]; // x is allocated through the ArenaAllocator
    #set_allocator(#env.default_allocator);
    $println(x); // allocates via default allocator
    #set_allocator(arena);
    #env.allocator.free_self(); // frees the arenas
    #set_allocator(#env.default_allocator); // go back to default allocator
}
#

maybe i should be more specific

runic sundial
#

Yeah

#

Also get yourself the

#

deferred

#

Keyword

#

ASAP

valid jetty
#

better?

* `MyAllocator::free(MyAllocator *self, void *ptr)` (frees a specific object passed by pointer, may be omitted if permitted by the allocation model, will become `noop`)
* `MyAllocator::free_self(MyAllocator *self)` (destructor for the allocator itself including all of its allocations, **NOT** objects created by it)
valid jetty
runic sundial
#

Epic

valid jetty
#
use std/io;

fn main() {
    let size = 10;
    i64 *numbers = mem::malloc(size * #size(i64));
    defer mem::free(numbers);

    for let i = 0; i < size - 1; i += 1 {
        numbers[i] = i * 2;
        let res = numbers[i];
        io::printf("numbers[{}] = {}", i, res);
    }

    if numbers[2] + 1 * 5 == 10 {
        // Calls `free` here
        return 1;
    }

    // Calls `free` here
}
runic sundial
#

It's very useful for memory management

valid jetty
#

or in the case of custom allocators actually 1 sec

runic sundial
#

Also errdefer

valid jetty
#
use std/prelude;
use std/allocators/heap;

fn main() {
    #set_allocator(HeapAllocator::new());
    size := 10;
    numbers := #alloc(i64, size);
    defer #free(numbers);

    for i in 0..size - 1 {
        numbers[i] = i * 2;
        res := numbers[i];
        io::printf("numbers[{}] = {}", i, res);
    }

    if numbers[2] + 1 * 5 == 10 {
        // Calls `free` here
        return 1;
    }

    // Calls `free` here
}
``` """*modern*""" elle
runic sundial
#

Also allocators

#

How do you handle it between thread scopes?

valid jetty
#

threading is not exactly something im working on at the moment lol

runic sundial
#

No like looking into the future

#

Would this need a whole ass rework for it?

valid jetty
#

i have no idea xd

runic sundial
#

Trolley

#

Global state moment

#

Guess async corotuines would also be out of the question then

valid jetty
#

making the current allocator be a mutex sounds kinda painful

runic sundial
#

Zig just treats em as a struct

#

Shrimple as

valid jetty
#

then i found a better solution (or well simpler and more portable) so platform specific asm wasnt needed

#

unfortunately thats not possible for coroutines because you need to save registers which is very platform specific

winged mantle
#

javascript sexism???

native spruce
#

@woven mesa how do u do your uikit list with swiftui

woven mesa
native spruce
#

but i find uiviewrepresentable odd

native spruce
#

app switcher?

woven mesa
native spruce
woven mesa
#

no problem oomf

#

sorry its not the simplest and also even buildable code sample

native spruce
woven mesa
#

im just eepy

#

uhh its not configured for it

#

but it wouldnt be difficult to implement

#

actually @native spruce it would work i think bc it calls reloaddata on the table

native spruce
#

oki

valid jetty
#

did i yap too much

winged mantle
#

it'd be so nice if you could just get typescript to return unknown instead of any when indexing on unknown key

#

currently it seems you have to use as keyof whatever to get it to work but if circumstances change this could stop being safe

valid jetty
winged mantle
#

how would that work with lsp though

valid jetty
#

wdym

#

its just a package that edits a bunch of types to return unknown instead of any

#

it would just work as if it was returning unknown to begin with

winged mantle
#

ah i do not believe you said stdlib types before editing it

#

the issue here is indexing objects

#

this is any instead of unknown

#

I tried turning on noExplicitAny again but it is such a pain

#

even if you put unknown it has an error

native spruce
#

but is it beautiful

#

I use a uicollectionview because of speeds

#

list and lazyvgrid sadly don't meet up to my standards :c

native spruce
#

swiftui is pissing me off I think

native spruce
#

ngl I may just choose uikit for this view because holy shit lol

#

combining swiftui and uikit stuff has never been so difficult

formal belfry
#

I think SwiftUI is a good option sometimes and then I use it and then I regret it immediately because one really valuable modifier is missing or something

native spruce
#

swiftui is good for simple views with not much complexity

#

but when you want something that’s performant (like using a uitableview or collectionview) there will be problems

#

For example pushing a swiftui view from a uiviewrepresentable is horrible

native spruce
#

there goes my hopes and dreams

frosty obsidian
#

swiftui just keeps sounding like compose but if a quarter of its apis were deprecated

native spruce
frosty obsidian
#

closest would be the view system

native spruce
#

but this is not related to deprecated apis

frosty obsidian
#

but it uses layout xml files

#

if you hate yourself you can do it all programmatically

native spruce
#

well uikit is like that but it also has an option to not use xml layouts

#

I do it programmatically

#

(imo the proper way of doing it)

frosty obsidian
#

its just extremely verbose in android land

#

most devs will just do the basic layout in xml and make it functional in code

native spruce
#

lovely isnt it

frosty obsidian
#

(it is technically faster since no xml parsing is needed)

native spruce
#

telegram devs so good

frosty obsidian
#

its only really beneficial for very low end devices

#

typically very old ones

#

as telegram supports some ancient android versions

frosty obsidian
#

my apps actually support older versions

valid jetty
#

beautiful

native spruce
#

uihostingcontroller?

#

navigationDestination?

woven mesa
#

UIHostingConfiguration works perfectly

native spruce
#

I said pushing a swiftui view not UIHostingConfiguration

woven mesa
#

o

#

mb

native spruce
#

like onto the navigationstack

woven mesa
#

is navigation link breaking

native spruce
woven mesa
#

introspect and manually push a new view to the stack

#

wrap your new swiftui view with uihostingconfiguration and push that

native spruce
#

wouldn't that just use a uihostingcontroller

#

reminder I said without a uihostingconfiguration

icy needle
#

i spent several days trying to get method access to work properly like an idiot

#

then realized pratt parsing just makes it work out with no effort anyway

valid jetty
#

why are curly brackets unary operations

icy needle
#

i thought it made sense

#

if you have one item in brackets, it fills up the only slot

#

if you have 2, you use a comma which is a binary op

#

for more, you chain commas

#

tho i'll probably have to restructıre them into a list

icy needle
placid cape
#

do you want it to be compiled?

valid jetty
#

interesting

valid jetty
#

which means that the field access thing is unpredictable (its the wrong way around)

icy needle
icy needle
#

so i did, and i'm glad that i did

valid jetty
#

although i dont do namespace accessing like that lol

#

1 sec

#

i honestly dont know what else to do now

#

lmao

#

maybe its finally time to make some enums

#

or like refactor the 4.5k line compiler into multiple files

icy needle
#

yeah that's kinda weird imo too

#

basically for me they work like regular math operators

#

so left to right and respecting priority

#

if an op has a later order, it swallows the earlier order ones before it in the tree

#

that's basically how pratt parsing works

valid jetty
#

thats how i wish i did it tbh but oh well

#

i do that for ranges tho lol

#

.. is an arithmetic operator that takes in lhs and rhs and calls a function that creates a range out of them

placid cape
#

and is it open source?

icy needle
#

so probably qbe

placid cape
#

yeah qbe is nice for start

icy needle
#

idk how usable tilde is

placid cape
#

i need to finish my parser refactor

valid jetty
#

also theres like no documentation on it yet

#

qbe doesnt have lots but it as at least a litt;e biot

placid cape
#

what are you talking about?

placid cape
#

interesting

placid cape
valid jetty
#

its too simple for that

#

i started it off with it and now i regret it because the compiler is too complicated to represent some programs in qbe and i need to do a lot of heavy lifting in the front end

placid cape
#

any examples?

valid jetty
#

generics, deferring, custom allocators are all compilation gimmicks, qbe has no way to do any of that stuff

#

dynamic dispatch too

#

i want to have dynamic dispatch because its very useful but qbe just makes it very hard as its so simple

#

not that llvm has that stuff either but its type system is a lot stricter which makes it easier in the end

placid cape
#

understand

valid jetty
#

a simple program like this

use std/prelude;
use std/allocators/heap;

fn main() {
    #set_allocator(HeapAllocator::new());
    x := #alloc(i32);
    #set_allocator(#env.default_allocator);
}
#

oh

#

lol

#

the assembly is even worse

#

and keep in mind this is with a runtime so most functions that are used dont even have their bodies

#

im thinking

#

would it be a good idea to get rid of the /std prefix?

#

so you can do use prelude; and use allocators/heap; directly

placid cape
#

nah

valid jetty
#

i can do that really easily

placid cape
#

keep it

valid jetty
#

hmm ok

brave moss
placid cape
valid jetty
#

i was thinking because some modules can be quite lengthy to type out like use std/collections/hashmap;

#

or use std/runtime/allocators/arbitrary;

valid jetty
placid cape
#

i would keep it as it is

valid jetty
#

maybe thats for the better tbh

brave moss
valid jetty
#

elle

placid cape
#

elle

#

and i have blom

valid jetty
#

blom!!

#

bloom

placid cape
#
fun @native printf(format: string, ...) -> i32;

fun @infix lol(left: i32, right: i32) -> i32 {
  return left + right;
}

fun @infix lol(left: string, right: i32) -> i32 {
  return 99 + right;
}

fun @infix lol(left: i32, right: string) -> i32 {
  return left + 99;
}

fun @public main() {
  printf("%d\n", 5 lol 3 lol 9 lol "a");
  return 0;
}
valid jetty
#

broom

placid cape
#

infix

#

you can put the annotations anywhere

#

so you can also do @public fun main() now

valid jetty
#

that sounds really hard to make i would struggle with that

#

not the annotations

#

but overloaded infix functions

placid cape
#

you mean infix

#

yeah its horrible

#

parsing infix functions is the biggest mistake i ever done

#

i need to figure out how to do it properly

valid jetty
#

i literally got rid of the incrementing operator (aka postfix and prefix) from elle because it caused so much parsing and compiling slop lol

placid cape
#

i want to keep the syntax as simple as possible

valid jetty
#

maybe one day ill do the go thing and make it a statement and ONLY let you do x++

#

yeah thats what im doing mostly

placid cape
#

so i really dont want things like ?. etc like in js

valid jetty
#

i have a small set of things and im extending existing ones

placid cape
#

ill also rework the field access to be just a math operator, like @icy needle

valid jetty
#

im adding a lot of things to this

#

maybe ill add a #reset_allocator(); which does #set_allocator(#env.default_allocator) for you

placid cape
#

compile time functions 👍

valid jetty
#

ya

#

imo better than stuff in C where it looks just like a regular function

#

the # thing is inspired from rust with the ! for macros

placid cape
#

i just have @ like in zig

#

but ill probably change it bcs now i have problems to figure out what is an annotation and what's a compile time function

#

since each statement can potentially have annotations

valid jetty
#

yeah thats why i made them different lol

#

i just have a thing called sigils

placid cape
#

👍

#

i also dont want to end up like ruby where you dont know what are you parsing lol

valid jetty
#

lol so easy

fn parse_reset_allocator(&mut self) -> AstNode {
    let location = self.current_token().location.clone();
    self.advance();

    self.expect_tokens(vec![TokenKind::LeftParenthesis]);
    self.advance();

    self.expect_tokens(vec![TokenKind::RightParenthesis]);
    self.advance();

    AstNode::SetAllocator {
        value: Box::new(AstNode::FieldAccess {
            left: Box::new(AstNode::Environment {
                value: None,
                location: location.clone(),
            }),
            right: Box::new(AstNode::Literal {
                kind: TokenKind::Identifier,
                value: ValueKind::String("default_allocator".into()),
                location: location.clone(),
            }),
            value: None,
            location: location.clone(),
        }),
        location,
    }
}
placid cape
#

implement tail call recursion optimalization blobcatcozy

valid jetty
#

eventually

#

ok it works

#

that was fast

icy needle
#

or i could do the vlang meme and transpile to c

valid jetty
#

true

austere anchor
#

coding for Elle in the morning goes crazy

#

gm

valid jetty
#

gm

placid cape
#

gm

valid jetty
#

literally 32 additions for a whole new builtin

placid cape
#

the hardest thing is to start and make a proper structure

austere anchor
#

@valid jetty support for aligned allocs?

valid jetty
#

alocs on heap are aligned to ptr width which is usually also 8 bytes

#

but no way to set custom alignment yet

#

qbe supports it, there is alloc4, alloc8, alloc16 for stack

#

and i could just allow for custom alignments in the allocators thats not particularly hard