#๐Ÿช…-progaming

1 messages ยท Page 30 of 1

hoary sluice
#

they are pointless in the stdlib

valid jetty
#

theyre useful for my graphics examples

hoary sluice
#

people would lant their own impl

#

can u make extension functions

valid jetty
#

yes

#

of

#

of

#

ofc

#

lol

hoary sluice
#

ok then its fine

valid jetty
#
for let theta = 0.0; theta < 2 * PI; theta += THETA_SPACING {
    f32 sinTheta = math::sin(theta);
    f32 cosTheta = math::cos(theta);

    for let phi = 0.0; phi < 2 * PI; phi += PHI_SPACING {
        f32 sinPhi = math::sin(phi);
        f32 cosPhi = math::cos(phi);

        let surfacePos = Vector3 {
            x = cosPhi * (cosTheta + 2),
            y = sinPhi * (cosTheta + 2),
            z = sinTheta,
        };

        let depth = 1 / (surfacePos.y * sinRotX + surfacePos.z * cosRotX + 5);
        let projectionOffset = surfacePos.y * cosRotX - surfacePos.z * sinRotX;

        i32 x = 30 + 36 * depth * (surfacePos.x * cosRotZ - projectionOffset * sinRotZ);
        i32 y = 12 + 12 * depth * (surfacePos.x * sinRotZ + projectionOffset * cosRotZ);
        i32 offset = x + WIDTH * y;

        let normal = surfacePos.clone();
        let normalLengthSquared = normal.length_sq();

        if normalLengthSquared > 0 {
            normal = normal.scale(1.0 / normalLengthSquared);
        }

        let illumination = normal.dot(*lightDirection);
        let lightingIndex = (i32)(math::abs(illumination) * (LIGHTING.len() - 1));

        if HEIGHT > y && y > 0 && x > 0 && WIDTH > x && depth > zBuffer[offset] {
            zBuffer[offset] = depth;
            let lightingMapping = (i32)lightingIndex % (LIGHTING.len() - 1);
            output[offset] = LIGHTING[lightingMapping < 0 ? 0 : lightingMapping];
        }
    }
}
``` i wrote the donut ascii thing from scratch using vectors
#

its useful to have

placid cape
#

and then java: Vector is legacy ArrayList blobcatcozy

valid jetty
#

technically normal can be surfacePos.clone() i forgot thats a thing now

valid jetty
hoary sluice
#

did u steal a c impl

valid jetty
#

no

#

if you scroll down

#

theres the math behind it

hoary sluice
#

ah ok

#

im not gonna understand anything

valid jetty
#

lmfaoo

#

theres a pseudocode impl at the bottom but that doesnt use vectors

#

or at least not directly

hoary sluice
#

thats so fast

#

sleep longer

valid jetty
#

lmfao

#

i guess

#

shrug

#

mostly the lighting is broken i think

placid cape
#

@hoary sluice how are you gonna make module importing

#

like what keyword

valid jetty
#

no modules

#

must copy paste all source code into your file

hoary sluice
valid jetty
#

so many lol

#

technically prelude imports more things but the compiler sees that theyre already imported and doesnt go to import them again

hoary sluice
#

ok @valid jetty it makes no sense for function declarations to be expressions

valid jetty
#

it really doesnt unless youre a pure fp lang

#

and functions are first class citizens of the language

hoary sluice
#

not even haskell has that

valid jetty
#

oh true

#

well technically

hoary sluice
#

and i made lambdas

valid jetty
#

creating lambdas is an expression

valid jetty
hoary sluice
#

so it makes even less sense

hoary sluice
hoary sluice
#

they are just a new scope

valid jetty
#

can you do like map (\x, y -> * x y) [(1, 2), (3, 4), (5, 6)]

valid jetty
hoary sluice
#

and its not an expression

valid jetty
#

yeah lol that should be an stmt

#

but \x, y, z -> (+) x y z should be an expr

hoary sluice
valid jetty
#

ok yeah good

#

@placid cape try write this in blom

use std/io;

fn direction(i32 *other) -> bool {
    return !other ? direction(&0) : &0 > other;
}

fn main() {
    io::printf(
        "The stack is growing {}wards for your architecture.",
        direction(nil) ? "up" : "down"
    );
}
hoary sluice
#

function syntax is now

add int int _ $ x y = x + y

// or

add int int _
add x y = x + y
#

or u can inline with a lambda

valid jetty
#

the devious map<i32> in question

hoary sluice
valid jetty
#

oh the return type

#

i see

hoary sluice
#

there is no return type

#

its fp

valid jetty
#

what is it inferring then

hoary sluice
#

but yea

hoary sluice
valid jetty
#

๐Ÿ˜ญ

#

fuck i forgot

#

there

#

ok i mean all the tests pass

#

ill run my aoc solutions to make sure they all pass but if they do then ill push

#

then i can continue working on the env

hoary sluice
#

u could do smth like

otherfunc int int int int int int
// implement

abc int int _ _ _ _ $ x y = x otherfunc y
valid jetty
#

oh horror

#

im sure you could use that for golfing

hoary sluice
#

and variables are just

a int = 7
a _ = 7

which is why i wanted to use _

valid jetty
#

in elle the extent of inferring is

  1. inferring the return type based on the type of the values you return (checks to make sure there isnt more than 1)
  2. let which basically gets rid of the lhs being used to infer information from the rhs (such as in Array::new<T>())
  3. inferring in for x in y loops (basically just sets the current value to use let internally lol its the same mechanism)
valid jetty
#

looks like it would be really confusing to debug

hoary sluice
valid jetty
#

oh my god

valid jetty
#

imo the way i do it is kinda nice maybe

#
let x = 1;
``` if it can be inferred, if you need to supply extra info such as in arrays you have 2 options
```rs
let arr = Array::new<i64>();
``` or
```rs
i64[] arr = [];
#

i dont like rust's way where you have

let x = 1;
``` or
```rs
let arr = Vec::new::<i64>();

or

let arr: Vec<i64> = vec![];
valid jetty
#

yeah but in rust you have to write both let and the type

#

i dont like that

hoary sluice
#

no u dont

placid cape
hoary sluice
#

oh nvm

#

thats what u mean

placid cape
hoary sluice
#

yea

placid cape
#

need to implement pointers

#

and compile time function is not only compile time anymore heh

#

ill rename them to builtins or something

valid jetty
#

oh in rust you actually cant even Vec::new::<i64>() it MUST be inferred from the type of lhs

#

Vec::new takes no generics

hoary sluice
#

no

valid jetty
odd lake
#

yes

valid jetty
#

must be inferred from lhs

hoary sluice
#
Vec::<i64>::new()
odd lake
#

^

#

That's the better syntax

valid jetty
#

oh thats evil

odd lake
#

Not inferred

#

Why is that evil

#

It's just moving the generic

valid jetty
#

yeah i guess

hoary sluice
#

this is valid too

#

inferred here

valid jetty
#

yeah i know because rust is really good at inferring based on what you push into it or where you store it

#

ok well i mean i guess its time

#

i like to use github desktop when the commit is huge

placid cape
#

wow

hoary sluice
#

read full commit read full commit read full commit read full commit read full commit read full commit read full commit read full commit

placid cape
hoary sluice
#

thats the only thing i dislike abt zed

#

(and that it doesnt support jvm/kt)

placid cape
#

nah i have vsc

valid jetty
#

oh

placid cape
#

okay i should fix this heh

valid jetty
#

lol this is why i use gh desktop

hoary sluice
#
expression = definition | if | lambda | op ;
definition = declaration | body ;
declaration = IDENTIFIER type { type } [ "$" { pattern } ] "=" expression ;
body = IDENTIFIER { pattern } "=" expression ;
lambda = "(" IDENTIFIER "$" expression ")" ;
if = "if" expression expression { "else if" expression expression } "else" expression ;

op = primary { IDENTIFIER primary } ;

primary = "true" | "false" | "null"
       | "(" expression ")"
       | NUMBER | STRING
       | IDENTIFIER ;

type = "_" | IDENTIFIER ;

pattern = "_"
       | "true" | "false"
       | NUMBER
       | STRING
       | IDENTIFIER ;

i think this is final

#

op is all operators with their precedence (resolved at runtime)

valid jetty
#

like noulith

#

fun

hoary sluice
#

exactly like noulith

placid cape
#

this is funny xdd (compiled also includes start time)

#

now i can finally calculate euler's number :)

valid jetty
#

you can do this which i think is a bit silly

for i in (let res = 1)..=10 {
    res *= i;
}

io::assert(res == 3628800, nil);
#

factorial

crimson sparrow
#

great for golfing

hoary sluice
#

are the {} still required

ember zealot
#

Hello, i keep getting a HTTP load failed with status 404. Load of media resource even though i have no such file? ๐Ÿ˜ญ the file is called play-when-spotify-detected.mp4. this is how i call it:

i think it's bcs i renamed the file to have is but i don't know why it's still consistently asking for the old version.

valid jetty
#

i did it

hoary sluice
# valid jetty i did it

read full commit read full commit read full commit read full commit read full commit read full commit

valid jetty
#

yep

#

now im gonna continue implementing the env (it wont use the actual qbe env because i wanna save that for closures)

#

because this is not it

#

lmfao

ember zealot
#

I don't know how to fix it

hoary sluice
#

name the file the same?

ember zealot
hoary sluice
#

its called is-detected

valid jetty
ember zealot
#

I think it's smth to do with audioPlayer.src, but when i tried to change it, it js used the same thing

valid jetty
#

not the same name

ember zealot
#

๐Ÿ˜ญ

#

Yeah it works perfect now

valid jetty
#

lmaooo

ember zealot
#

๐Ÿ˜ญ

#

Thank you to u two

hoary sluice
#

nv

valid jetty
#

ok i pushed all my changes to my aoc solutions

#

i wanna try to get them all done before the new year aaaa

#

i have to do 7.5 days in 2 days

#

because day 25 only has 1 part and because its already 6pm

placid cape
#

but ehhhh

#

i must fix this

hoary sluice
#

@valid jetty @placid cape is it horror if i store function names that have already been declared in my parser to disambiguate between function declarations and function bodies since theyre both just a bunch of identifiers

placid cape
#

I'm saving all function names

#

map of name and declaration statement

#

but I'm doing it in my analyzer and compiler

hoary sluice
#

maybe i should rethink my function syntax again

placid cape
#

and I should rethink my compiler

#

I'll probably do something like rosie, creating another AST which will be more low level

valid jetty
#

mine does not create a more low level ast

placid cape
#

it doesn't?

hoary sluice
#

maybe i just need to accept that :: is inevitable

#
add : Int Int
add a b = a + b

fact : Int Int
fact 0 = 1
fact n = fact (n - 1)
#

and no same line body

#

thats too confusing

valid jetty
# placid cape it doesn't?
fn main() {
    let x = 1 + 1;
}
Function {
    name: "main",
    arguments: [],
    return_type: Some(Word),
    blocks: [
        Block {
            label: "start",
            statements: [
                Assign(Temporary("x.addr.1764"), Pointer(Word), Alloc8(Const("", 4))),
                Assign(Temporary("tmp.1762"), Word, Add(Const("", 1), Const("", 1))),
                Volatile(Store(Word, Temporary("x.addr.1764"), Temporary("tmp.1762"))),
                Volatile(Return(Some((Word, Const("", 0), examples/test.le:1:8)))),
            ],
        },
    ],
}
#

just a rust-based representation of the qbe

hoary sluice
#

but at that point i might as well just use haskell ๐Ÿ˜ญ

valid jetty
#

no ast here

hoary sluice
#

i dont wanna make haskell without the ->

placid cape
#

i see how you're doing it

#

I'm doing pretty much the same but worse

#

I'll rewrite the compiler again

hoary sluice
#

wait ocaml, F# and ml are all related???????

placid cape
#

I'll also create enums etc for it to represent it better

valid jetty
#

its so hard to explain this lol

placid cape
#

well let infers to the smallest possible size but not smaller than i32, or?

valid jetty
#

no, let basically gives the rhs no information about the type it should be, so 0 becomes the default integer literal size which is i32

valid jetty
#

youtube running in chromium running in your terminal

placid cape
#

Omg math equation captcha because computers doesn't know how to solve it

#

Lmao

royal nymph
#

WHAT IS THAT LINK

placid cape
#

So it contains jwt

valid jetty
#

its not private tho

placid cape
#

then idk why it has jwt lol

valid jetty
#

yeah idk

#

github copied the link weird

#

ๆ•ฐๅญฆใซใŠใ„ใฆใƒ•ใƒผใƒชใ‚จๅค‰ๆ›๏ผˆใƒ•ใƒผใƒชใ‚จใธใ‚“ใ‹ใ‚“ใ€่‹ฑ: Fourier transformใ€FT๏ผ‰ใฏใ€ๅฎŸๅค‰ๆ•ฐใฎ่ค‡็ด ใพใŸใฏๅฎŸๆ•ฐๅ€ค้–ขๆ•ฐ

    f
  

{\displaystyle f}

ใ‚’ใ€ๅˆฅใฎๅŒ็จฎใฎ้–ขๆ•ฐห†fใซๅ†™ใ™ๅค‰ๆ›ใงใ‚ใ‚‹ใ€‚
ๅทฅๅญฆใซใŠใ„ใฆใฏใ€ๅค‰ๆ›ๅพŒใฎ้–ขๆ•ฐห†fใฏใ‚‚ใจใฎ้–ขๆ•ฐ

    f
  

{\displaystyle f}

ใซๅซใพใ‚Œใ‚‹ๅ‘จๆณขๆ•ฐใ‚’่จ˜่ฟฐใ—ใฆใ„ใ‚‹ใจ่€ƒใˆใ€ใ—ใฐใ—ใฐใ‚‚ใจใฎ้–ขๆ•ฐ

    f
  

{\displaystyle f}

ใฎๅ‘จๆณขๆ•ฐ้ ˜ๅŸŸ่กจ็พ (frequency domai...

#

@hoary sluice

placid cape
#

Mixing Japanese chars with latex

valid jetty
#

its mostly kanji because theyre technical terms

placid cape
#

idk ii dont know japanese

#

gonna create another module called qbe which will have all definitions/enums for qbe

#

and then the compiler will just use them like yours

#

thats a way better

valid jetty
placid cape
#

thx

#

i also looked for golang ones but didnt find anything maintained so i'll do my own

valid jetty
#

ah

#

idk this one wasnt extensible enough for me

placid cape
#

having own is better

#

qbe isnt that big

valid jetty
#

i used it as a reference in the begining but now mine is completely different lol

placid cape
#

so its okay

valid jetty
#

its a mess

placid cape
#

yeah i alr looked into yours

#

and thats why i want it in multiple files and not one

valid jetty
#

lmfao

#

maybe 1 day ill do that

placid cape
#
package qbe

import (
    "errors"
    "fmt"
    "slices"
)

type Type int

const (
    UnsignedByte Type = iota
    UnsignedHalfword
    UnsignedWord
    UnsignedLong
    Byte
    Halfword
    Boolean
    Word
    Long
    Single
    Double
    Char
    String
    Void
    Null
)

var humanTypes = []string{
    UnsignedByte:     "u8",
    UnsignedHalfword: "u16",
    UnsignedWord:     "u32",
    UnsignedLong:     "u64",
    Byte:             "i8",
    Halfword:         "i16",
    Boolean:          "bool",
    Word:             "i32",
    Long:             "i64",
    Single:           "f32",
    Double:           "f64",
    Char:             "char",
    String:           "string",
    Void:             "void",
    Null:             "null",
}

var types = []string{
    UnsignedByte:     "ub",
    UnsignedHalfword: "uh",
    UnsignedWord:     "uw",
    UnsignedLong:     "ul",
    Byte:             "b",
    Halfword:         "h",
    Boolean:          "w",
    Word:             "w",
    Long:             "l",
    Single:           "s",
    Double:           "d",
    Char:             "c",
    String:           "l",
    Void:             "",
    Null:             "",
}

func ParseType(str string) (Type, error) {
    index := slices.Index(humanTypes, str)
    if index == -1 {
        return 0, errors.New(fmt.Sprintf("Unknown type '%s'", str))
    }

    return Type(index), nil
}

func (t Type) HumanInspect() string {
    return humanTypes[t]
}

func (t Type) String() string {
    return types[t]
}

func (t Type) IsNumeric() bool {
    return t.IsInteger() || t.IsFloatingPoint()
}

func (t Type) IsInteger() bool {
    return t == UnsignedByte || t == UnsignedHalfword || t == UnsignedWord || t == UnsignedLong || t == Byte || t == Halfword || t == Word || t == Long
}

func (t Type) IsFloatingPoint() bool {
    return t == Single || t == Double
}
#

my types

#

well actually char, str, boolean, void and null shouldnt be there

#

i took that from yours

hoary sluice
valid jetty
placid cape
#

yea i know

#

copilot moment

valid jetty
#

char is different from i8 for me because it displays differently

#

char displays with %c i8 displays with %d

placid cape
#

yea yea

#

gonna make instructions

#

really miss enum with values aaah

hoary sluice
#

does elle make a distinction between primitiver and structr

#

omg its so annoying when s is next to r

#

looks so silly

valid jetty
#

structs are a primitive

#

oh

#

oh

#

yes

#

in general the convention is that structs are capitalized and primitives arent

hoary sluice
#

how about caps are a compilation error

valid jetty
#

nono you can define structs just like any identifier

#

its how i plan to add i128 support when i add dunder methods for add sub mul div

hoary sluice
placid cape
#

copilot saves me rn

#

its just generating it for me xd

#

amazing

valid jetty
#
use std/prelude;struct FEIN{i8 _;};

fn FEIN::__equals__
(FEIN
FEINN
,FEIN
FEINNN){
return
FEINN
._==
FEINNN
._;}fn

FEIN_FEIN
(FEIN FEINN
,FEIN
FEINNN){
io::dbg(
FEINN
== FEINNN ?


"FEIN": "FEIN"
    );}fn
    main
    () {
    let
FEINN=FEIN{_


=39       };let
FEI =     FEIN
    {_ =
        39   }
;FEIN_FEIN(FEINN
,FEI);}

pearl stagBOT
# hoary sluice https://github.com/eagely/icps/blob/main/src/grammar.ebnf

grammar.ebnf:

expression = body | declaration | if | lambda | op ;
body = IDENTIFIER { pattern } "=" expression ;
declaration = IDENTIFIER ":" type { type } ;
if = "if" expression expression { "else if" expression expression } "else" expression ;
lambda = { IDENTIFIER } "$" expression ;
op = primary { IDENTIFIER primary } ;

type = "_" | IDENTIFIER ;

pattern = "_"
       | "true" | "false"
       | NUMBER
       | STRING
       | IDENTIFIER ;

primary = "true" | "false" | "null"
       | "(" expression ")"
       | NUMBER | STRING
       | IDENTIFIER ;

valid jetty
hoary sluice
#

theres ebnf syntax highlighting???

placid cape
hoary sluice
#
hello = omg
placid cape
#

or am i missing something?

hoary sluice
placid cape
#

no

#

it's QBE

#

this is my binary expression in ast

valid jetty
hoary sluice
#

why are yall putting location in ast

#

and in the token

#

pick one

placid cape
#

i dont have location in tokens

valid jetty
placid cape
#

only in ast

#

oh no i have also in token sorry xd

hoary sluice
valid jetty
placid cape
hoary sluice
valid jetty
#

also consider most nodes dont contain tokens

hoary sluice
#

@placid cape perfect timing https://youtu.be/xSyUvkpHv6M

I love Arch Linux and I always will so when I came across this survey on the Arch Linux subreddit I knew I had to go through it and talk about my experience on Arch.

==========Support The Channel==========
โ–บ Patreon: https://brodierobertson.xyz/patreon
โ–บ Paypal: https://brodierobertson.xyz/paypal
โ–บ Liberapay: https://brodierobertson.xyz/liberap...

โ–ถ Play video
placid cape
#

lol

hoary sluice
placid cape
#

im not gonna use archlinux anymore

valid jetty
#

tokens where

hoary sluice
#

or at least nested

placid cape
#

i broke my whole system just by installing mysql package

hoary sluice
valid jetty
#

this isnt aoc

hoary sluice
#

if is the only thing without a token

valid jetty
#

there are some with tokens

#

literals arent statements theyre just called that because i was silly when i wrote that

hoary sluice
#

speaking of statements

#

actually no this ast is completely wrong

#

doesnt match my grammar

valid jetty
#

zed can refactor whole symbols

#

even here

#

it knows

#

holy shit

hoary sluice
#

so can every other ide

valid jetty
#

this is new to me after using vanilla nvim for a while

hoary sluice
#

(how do u do it in zed tho)

valid jetty
hoary sluice
valid jetty
#

oh

#

ill use a naming convention of X if an expr but YStatement if a statement

hoary sluice
#

just do x and y

placid cape
#

252 lines in rust, 445 in go @valid jetty

#

value enums are op

hoary sluice
#

ur rewriting in rust???

#

this is all i need in life

#

@placid cape what de do u use

placid cape
placid cape
#

yes, google chrome on linux

#

and youtube music with auto play

hoary sluice
#

i mean what desktop env

#

kde, gnome, a tiling wm?

placid cape
#

swayfx

calm ruin
hoary sluice
#

nice

hoary sluice
valid jetty
#
use std/prelude;

fn main() {
    // Ranges create arrays for the time being
    io::assert(5..10 == [5, 6, 7, 8, 9], nil);
    io::assert(3..=8 == [3, 4, 5, 6, 7, 8], nil);

    for i in (let res = 1)..=10 {
        res *= i;
    }

    io::assert(res == 3628800, nil); // 10! (factorial)
    io::println("All range tests have passed!".color("green").reset());
}
``` this runs in <1ms suprisingly
hoary sluice
valid jetty
#

thats fast wtf

valid jetty
#

i need to get rid of arc soon

placid cape
hoary sluice
#

its 10! itd be very bad if that took longer than a ms

placid cape
#

when i need to calculate something i just open kitty (terminal)

hoary sluice
valid jetty
placid cape
hoary sluice
#

nmcli and bluez?

#

yep

placid cape
#

and for screenshots i have bindsym Mod4+Shift+s exec sh -c 'filename="/tmp/$(date +%F_%T).png"; grim -g "$(slurp)" "$filename" && wl-copy < "$filename"'

valid jetty
hoary sluice
#

idk i spent like a year on hyprland and at some point just had enough of the various things that a de has that a wm doesnt; calculator, bluetooth / wifi gui, consistent theming (dont have to mix gtk and qt apps)

hoary sluice
valid jetty
#

ghostty is so nice holy shit

#

i love it

#

so minimalistic

hoary sluice
#

send ur config

valid jetty
#

background-opacity = 0.7
background-blur-radius = 30
theme = catppuccin-mocha
font-family = Maple Mono
window-padding-x = 16
window-padding-y = 16
window-height = 26
window-width = 90

hoary sluice
#

i dont like the bar

valid jetty
#

you can get rid of it

hoary sluice
#

and i havent found a way to remove it

#

how

hasty vessel
valid jetty
hoary sluice
#

ok now its awesome

valid jetty
#

the ultimate minimalistic setup

placid cape
hoary sluice
valid jetty
#

oh the blur doesnt work on non-macos

placid cape
#

hmm maybe ill try ghostty, kitty works and is nice

valid jetty
#

oh well

hoary sluice
#

i have been suffering with this title bar for weeks, i couldnt find the config option for it, pretty sure it was merged recently

placid cape
#

okay instruction &ย comparison done

valid jetty
hoary sluice
#

wtf

#

2 weeks ago there was nothing

valid jetty
#

idk maybe it was an option but not documented

hoary sluice
#

it was

#

i looked up remove title bar

#

there were a few people saying to set some env variables

valid jetty
#

is it time for day 18 in elle

hoary sluice
#

didnt work

valid jetty
#

i did it with A* ๐Ÿ˜ญ

hoary sluice
#

oh the padding is nice

valid jetty
#

at least i have these extensions now

fn Array::heap_pop<T>(T[] pq) -> T {
    if pq.is_empty() {
        return nil;
    }

    let result = pq.first();
    pq[0] = pq.last();
    pq.pop();

    let i = 0;
    while true {
        let smallest = i;
        let left = 2 * i + 1;
        let right = 2 * i + 2;

        if left < pq.len() && pq[left].x < pq[smallest].x {
            smallest = left;
        }

        if right < pq.len() && pq[right].x < pq[smallest].x {
            smallest = right;
        }

        if smallest == i {
            break;
        }

        let temp = pq[i];
        pq[i] = pq[smallest];
        pq[smallest] = temp;

        i = smallest;
    }

    return result;
}

fn Array::heap_push<T>(T[] pq, T value) {
    pq.push(value);
    let i = pq.len() - 1;

    while i > 0 {
        let parent = (i - 1) / 2;

        if pq[parent].x <= pq[i].x {
            break;
        }

        let temp = pq[i];
        pq[i] = pq[parent];
        pq[parent] = temp;
        i = parent;
    }
}
valid jetty
hoary sluice
#

why not make proper queues

valid jetty
#

effort

#

these functions also kinda assume that T is a tuple where T.x is comparable but whatever lol

#

not necessarily a tuple but any struct with a comparable x field

hoary sluice
#

@valid jetty @placid cape this is so useful

valid jetty
#

what ๐Ÿ˜ญ

hoary sluice
fleet cedar
#

I had that installed for years but found that I never used it so I nuked it

hoary sluice
#

how does this have 88k stars ๐Ÿ˜ญ

#

its the fucking #77 most starred repo on github

valid jetty
#

most starred unmaintained repo

#

surely

hoary sluice
#

its not unmaintained its just completed, perfect and doesn't need maintaining

valid jetty
#

true

hoary sluice
#

@valid jetty i literally breathe aoc and this is how i made a huffman code

#

notice how that is not a huffman code

valid jetty
#

๐Ÿ˜ญ

hoary sluice
#

Ive solved like 50 aoc problems that involve a priority queue but on a test i think that 3+4 <= 2+3

valid jetty
#

LMAO literally me

#

ive written > 10 implementations of bubble sort and quick sort in at least 4 languages but ask me to implement one in pseudocode during an exam and i wont be able to

ionic lake
hasty vessel
#

chatgpt is bad at plugins

placid cape
#

and still not done

#

1K lines

hoary sluice
#

i think i was born at the right time, old enough to have started with java and shitty ides and young enough to see my classmates do their entire thesis with chatgpt while being completely clueless

hasty vessel
hoary sluice
#

@valid jetty put a ui for elle in slopify

#

like make an online repl

placid cape
#

elle wasm

valid jetty
#

it cant compile to wasm

placid cape
#

okay im gonna rest for a while

#

then ill start rewriting the compiler

hoary sluice
#

qbe doesnt do wasm??

placid cape
valid jetty
placid cape
#

wasm doesn't support goto and jump

#

that's probably the biggest issue

valid jetty
#

yeah lol

#

wasm is like sort of high level for being asm

valid jetty
#

llvm supports wasm but thats llvm

hushed pebble
#

I've seen this same complaint when looking at QBE a week ago

#

to see how difficult it'd be to make a custom backend

#

I noticed someone asking about Wasm on the Sourcehut mailing list

valid jetty
hushed pebble
#

and like

#

Just use Binaryen's Relooper

hushed pebble
hushed pebble
valid jetty
#

to be fair nested loops are somewhat confusing with labels and goto

export function w $main() {
@start

@loop.5.cond
    jnz 1, @loop.5.body, @loop.5.end
@loop.5.step
    jmp @loop.5.cond
@loop.5.body

@loop.6.cond
    jnz 1, @loop.6.body, @loop.6.end
@loop.6.step
    jmp @loop.6.cond
@loop.6.body
    jmp @loop.6.step
@loop.6.end
    jmp @loop.5.step
@loop.5.end
    ret 0
}
hushed pebble
placid cape
hushed pebble
valid jetty
hushed pebble
#

C99 shit

#

idk how anyone understands that

placid cape
hushed pebble
valid jetty
placid cape
#

but ```c
static void
func(Fn *fn)
{

hushed pebble
valid jetty
#

no offense to qbe devs but what is this

hushed pebble
#

C99 probably doesn't support block-scoped variables?

#

but what the fuck is with their naming

fleet cedar
#

Fun fact: types can have more than 3 letters

valid jetty
#

LMAO

#

real

fleet cedar
#

Not that I'm one to speak

valid jetty
#

oh my god its not just a function pointer

#

its a fucking function linked list

hushed pebble
#

HUHHH?

placid cape
valid jetty
#

its a linked list of function pointers

hushed pebble
#

oh lord

placid cape
#

but qbe at least supports 60 chars husk

valid jetty
#

i never figured out which one it was

#

its either 64 or 80 chars

hushed pebble
#

probably 80 chars

#

everyone uses 80 chars

valid jetty
#

no because its defined in 2 places

#

one has 64 one has 80

hushed pebble
#

The width of a terminal is 80

valid jetty
#

let me first figure out what it is

#

then ill make an issue on the mailing list

hushed pebble
placid cape
#

okay im back on computer

valid jetty
#

its 80

placid cape
#

analyzer finally doesnt use compiler, dont ask why it uses it

placid cape
#

๐Ÿ‘

valid jetty
#

mandelbrot set in elle

#

written rendering to a texture at 1/4 resolution to maintain a decent framerate ๐Ÿซ 

placid cape
pseudo sierra
#

woah

placid cape
#

tomorrow ill work on the compiler

#

hopefully ill make it correct and robust

valid jetty
#

i did fancy zoom out for reset

#

nvm

valid jetty
#

ok this is valid so i have an idea

data $c = { l 0, l 0 }
data $formatter = { b "value is %ld\n", b 0 }

export function w $main() {
@start
    storel 1, $c
    %f =l loadl $c
    call $printf(l $formatter, ..., l %f)
    ret 0
}
#

ill make a #env directive which goes and loads the value at some global data section and interprets it as a region allocator

#

or well interprets it as an ElleEnv struct pointer

valid jetty
#

@hoary sluice @placid cape its so real

#

not passing anything to foo

#

it still allocates things

valid jetty
#

yes holy shit

#

it works

valid jetty
#

i turned args into real arg thing

#
use std/prelude;

fn main(string[] args) {
    io::dbg(args);
}
jade stone
#

go makes me want to tear my hair out

#

the build system and module/package system makes no fucking sense

#

all i want to do is build an executable

#

too confusing

torn seal
#

Write Zig

jade stone
#

never

valid jetty
#

lol it works but its slowwwww

#

im trying to change it to be an arena allocator but im getting stumped trying to free the nodes

dense sand
#

There should be a separate channel for language dev or rename this one, because theres nothing else here being discussed lol

ornate quiver
#

i hate go

hoary sluice
#

@valid jetty you are not human

viscid grove
#

timezones?
also not that late to stay up

dense sand
#

No like

#

Shes online all the time lol

placid cape
hoary sluice
pseudo sierra
#

sleep is bloat

placid cape
#

almost finished tests for my qbe abstraction

ornate quiver
#

who needs sleep

placid cape
#

another 1k lines blobcatcozy

hoary sluice
#

@valid jetty @placid cape i figured out how to make everything an expression (function declarations as expressions)

id : T T -- generic function

f : Int Int Int 
f g = g 42

x = f (id : Int Int) -- f takes Int Int, so id is typecast as Int Int since its generic
#

i think once i have inference this might only be useful for readability or specifying which generic types you want if youre passing id to another generic function

#
id : T T -- generic function

x = id : Int Int -- x is now id but can only take ints
#

this would actually be useful to specialize stdlib functions, maybe point.map requires deepcopying so you overload the map function for point specifically

placid cape
#

cool

dense sand
placid cape
#

Okay I guess I'll probably make the return value system of block expression/if expression same i as rust

#

it'll take the last statement

#

because I could rewrite return in these expressions to variable assignment but I don't want to do it

fleet cedar
#

If return keyword means return from block, how do you return from function

hoary sluice
#

@valid jetty have u seen the O(1) NP solver

placid cape
hoary sluice
#

if it is that also means im gonna have to solve an aoc day in icps types

#

and it would be really confusing

placid cape
#

so this will return 9:

function mm() {
i32 a = if 5 > 3 { 4 } else { 7 } 
return a + 5;
}

but if you do:

function mm() {
i32 a = if 5 > 3 { return 4; } else { return 7; } 
return a + 5;
}

it'll return 4

hoary sluice
#

are if else blocks equivalent to lambda blocks

placid cape
#

It's just expression

#

and all blocks

#

so same applies for

fun a() {
   {
      ....
   }
}
#
i32 a = {
    i32 c = 6;
    6 + 7
}
hoary sluice
#

in kotlin if you return from an if {} block you return from the function, but if you return from a lambda {} block you return from the lambda

placid cape
#

uh lol

#

I could do that but I would have to make two different returns - one if expression and one in statement

#

or i could replace return in expressions to assignment

hoary sluice
#

or make labels

#

if you cant early return a lambda you might get ugly code

placid cape
#

I wonder what's the best way tbh

#

I hate closures

fleet cedar
#

Returning from an outside scope from a lambda requires either funny scoped lambdas, or callCC

placid cape
#

I could also put everything into functions but I don't want to do that lol

#

hm wait

#

lambda is just a function and I don't threat function body as block expression

#

so that's okay

#

well I'll have the same behaviour as kotlin

hoary sluice
#

scopes arent that complicated

#

when u enter a scope u make a new nested env and if an identifier is unresolved u go to the parent env

placid cape
#

but it's a bit harder when you're generating code into IR

#

well maybe its not actually

valid jetty
#

and then i had to wake up at like 10am to go to an event thing

#

finally im home so i can debug it

#

i wouldve just stayed with my original region allocator but its slowwwwwwwwww

#

it takes like 275x longer to solve day 12 simply by using a different allocator

valid jetty
#

at least now itโ€™s setup in such a way where the allocator is abstracted away and i can just swap it out as needed

hoary sluice
#

@valid jetty installing gh desktop crashes my system

dense sand
hoary sluice
#

cause the diffs look better than in the terminal

hoary sluice
#

@valid jetty do you hate

#

(ignore the fact that half of those keywords dont exist)

valid jetty
#

no lol thats what i do

hoary sluice
placid cape
hoary sluice
#

๐Ÿ’€

valid jetty
#

ok this is so weird

#

im making a bump allocator

placid cape
#

this is FromIdentifier

valid jetty
#

it works

fn BumpAllocator::realloc(BumpAllocator *self, void *ptr, i32 new_size) {
    if new_size <= 0 {
        return nil;
    }

    if !ptr {
        return self.alloc(new_size);
    }

    if ptr < self.buffer || ptr >= (void *)((char *)self.buffer + (char *)self.capacity) {
        return nil;
    }

    i32 offset = (i32)((char *)ptr - (char *)self.buffer);

    if offset + self.used == self.used {
        if offset + new_size <= self.capacity {
            self.used = offset + new_size;
            return ptr;
        }
    }

    void *new_ptr = self.alloc(new_size);
    if new_ptr {
        i32 copy_size = new_size;

        if offset + new_size > self.used {
            copy_size = self.used - offset;
        }

        if copy_size > 0 {
            mem::memcpy(new_ptr, ptr, copy_size);
        }
    }

    return new_ptr;
}
``` but for some reason in day 12 it ends up being unable to memcpy at some point
#
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xfa677608)
  * frame #0: 0x00000001875df0d8 libsystem_platform.dylib`_platform_memmove + 520
    frame #1: 0x0000000100001d10 solution`BumpAllocator.realloc + 668
    frame #2: 0x000000010001601c solution`Array.resize.0.2.HashSet.0.2.Tuple.0.11.11.1.1.1 + 92
    frame #3: 0x00000001000160b0 solution`Array.push.0.2.HashSet.0.2.Tuple.0.11.11.1.1.1 + 92
    frame #4: 0x0000000100017860 solution`__internal.elle.__main__ + 5968
    frame #5: 0x0000000100017e7c solution`main + 572
    frame #6: 0x0000000187287e50 dyld`start + 2544
#

if i had to guess im reallocating wrong

hoary sluice
#

fuck i hate this

placid cape
#

fmt.Sprintf fail husk

hoary sluice
#

is in better to use Option<TokenValue> or have None in the TokenValue enum?

hoary sluice
placid cape
#

real

placid cape
#

where do you want Option<TokenValue>

hoary sluice
#

its easier for the parser if kind and value are separated

placid cape
#

๐Ÿ’€

#

perfect function call

valid jetty
placid cape
#

function calls done

valid jetty
#

address boundary error โค๏ธ

placid cape
#

idk why it throws that error but its cool that it doesnt even try to run it since its just an infinite loop

valid jetty
#

stack overflow?

placid cape
#

oh yea

#

@valid jetty why elle loads variable twice if you redeclare it?

hoary sluice
placid cape
#

this:

fn main() {
  i32 a = 5;
  a = 7;

  return a;
}
#

produces

export function w $main() {
@start
    %a.addr.57 =l alloc8 4
    storew 5, %a.addr.57
    storew 7, %a.addr.57
    %a.58 =w loadw %a.addr.57
    %a.58 =w loadw %a.addr.57
    ret %a.58
}
#

why loading again?

#

you probably forgot to remove the loading instruction since identifier literal takes care of it

placid cape
valid jetty
#

i need to load to return it from the expr

placid cape
#

oh like when you do return a = 3 ?

valid jetty
#

it allows you to do like
print(a = 7) and the return value of a = 7 is the loaded value from a.addr even though you might load it again later with an identifier literal

placid cape
#

ahhh

#

ig you can optimize it to load only if it's expression

valid jetty
#

theres not really a way to get rid of that second load other than optimization passes after the initial codegen

valid jetty
#

you have no idea if where you are right now is at the top level as an stmt or 5 recursions deep as an expr

#

the way you determine whether a node is an expr or stmt is whether you return Some((ty, val)) or None from the codegen for it

#

but as variable declarations are an expr theyre always an expr

placid cape
#

It's a bit weird that you have variable declaration and assignment as one token heh

#

but idk it's probably okay

valid jetty
#

declaration is also an expr

#

lets you do let x = let y = 1;

hoary sluice
valid jetty
#

yes

#

ignore the allocation stuff

#

the 1 is the important thing

#

let x = let y = 1 sets y to 1, then sets x to the value of y, then that itself is an expr so you get the value of x

placid cape
valid jetty
#

idk imo variable declarations being exprs is kinda fun

#

because then you can do this let x = (let y = 1) + 1;

#

now y is 1 and x is 2

#

or you can do ```rs
for i in (let res = 1)..=10 {
res *= i;
}

placid cape
valid jetty
#

yeah

#

this is so weird ๐Ÿ˜ญ omg

placid cape
placid cape
hoary sluice
#

@valid jetty when will elle transpile to malbolge

valid jetty
#

soon

valid jetty
# placid cape what

my allocations are aligned wrong in the arena allocator and eventually it allocates incorrectly and breaks

placid cape
valid jetty
#

Malbolge () is a public domain esoteric programming language invented by Ben Olmstead in 1998, named after the eighth circle of hell in Dante's Inferno, the Malebolge. It was specifically designed to be almost impossible to use, via a counter-intuitive 'crazy operation', base-three arithmetic, and self-altering code. It builds on the difficulty ...

#

basically a language designed to be as hellish as possible to use

hoary sluice
#

rust needs while let else

valid jetty
#

I GOT IT TO WORK

hoary sluice
valid jetty
#

ok well this is weird

#

when allocating a lot it fails to free most of it

#

there are quite a lot of leaked arenas

placid cape
#

upcoming zed-discord-presence version

frosty obsidian
#

insane

hoary sluice
#

this was my first commit in the old version

#

this is not how ur supposed to use git

placid cape
#

exactly

hoary sluice
#

mfw i made a whole ass interpreter in my first commit to the repo

placid cape
#

i commit every feature i add etc

hoary sluice
hoary sluice
placid cape
hoary sluice
placid cape
valid jetty
#

holy shit

#

omg

#

it only freed 1 arena

#

thats why it works for basic examples but not more complex ones

#

the chunk size for an arena is 64kb

#

so for a small example it all fit into 1 arena

#

my pointer indirection for the linked list was wrong

if self.current.used + size > self.current.size {
    Arena *arena = Arena::new(self.chunk_size);
    arena.next = self.current.next;
    self.current.next = arena;
    self.current = arena;
}
``` i honestly dont know what i was doing
#

it should be this

if (self.current.used + size > self.current.size) {
    Arena *arena = Arena::new(self.chunk_size);
    arena.next = self.current;
    self.current = arena;
}
hoary sluice
#

beautiful ast (only supports literals rn)

valid jetty
#

and now it frees all 700 arenas that were actually created for the day 12 thing

#

and its very fast too

valid jetty
#

nice

hoary sluice
#

im gonna struggle with this

placid cape
hoary sluice
#

gonna have to think of the parsing myself cause the syntax is unique, hopefully i wont have to redo my grammar again

valid jetty
#

insane

#

finally

#

i think this leaks report is wrong because it allocated a lot more than 18kb of memory

#

but i think the reason why it says only 18kb because the bigger allocations were virtual memory

hoary sluice
#

oh wait it overwrites self.current completely

valid jetty
# valid jetty but i think the reason why it says only 18kb because the bigger allocations were...

the OS is actually smart when asking for memory

it reserves virtual memory space but doesnt commit any physical memory until you actually acccess the memory (its called demand paging)

if i do this

for i in 0..1e5 {
    #env.allocator.alloc(1024 * 1024);
}
``` it almost allocates nothing on the physical memory even though it should allocate a lot more (it only allocates memory for the arenas themselves not the buffers inside)

but if you go and force the OS to commit the memory
```rs
for i in 0..1e5 {
    let ptr = #env.allocator.alloc(1024 * 1024);
    // force page commits by writing to the memory
    memset(ptr, 1, 1024 * 1024);
}
``` it actually uses all the memory

this behavior is actually really interesting because
- it allows for cheap large allocations as you only commit the memory you use
- it allows efficient over-allocations
#

In computer operating systems, demand paging (as opposed to anticipatory paging) is a method of virtual memory management. In a system that uses demand paging, the operating system copies a disk page into physical memory only when an attempt is made to access it and that page is not already in memory (i.e., if a page fault occurs). It follows th...

#

and in the case for my arena allocator its very fast

#

with arenas

#

oh wow

#

its actually even faster than pure malloc

#

AND it frees all the memory

placid cape
#

lol good job

placid cape
#

or 500 stars under 0.1ms

valid jetty
valid jetty
#

oh theres still print statements lol

#

me when

placid cape
#

it's cool that you're now at the stage where you're working on std

valid jetty
#

lol std has been a thing for a while

placid cape
valid jetty
#

since about the start of august i think

#

but i know what you mean

#

oh btw youre gonna love this

#

i wrote the entire custom main func in ast

placid cape
#

:DD

#

send

valid jetty
#
fn main(i32 argc, string *argv) {
    let env = ElleEnv { 
        allocator = ArenaAllocator::new()
    };
    #env = &env;
#if main_arg_len == 1
    let args = Array::with_capacity<string>(argc);
    let i = 0;

    while i < argc {
        args.push(argv[i]);
        i += 1;
    }

    let status = __internal.elle.__main__(args);
#else
    let status = __internal.elle.__main__();
#end
    env.allocator.free_self();
    return status;
}
``` basically this
#

written by hand in ast nodes

#

lmfao

valid jetty
#

no thats pseudocode

placid cape
#

oh okay

valid jetty
#

it has the same behavior

placid cape
#

Btw do you already use the env thing from qbe?

valid jetty
#

nope not yet

#

im saving that for closures if i ever implement them

#

#env is just storing a pointer in static memory

hasty vessel
valid jetty
#

is this enough constants yet

placid cape
#

you should refactor it heh

valid jetty
#

eventually probably

placid cape
#

not rewrite, just refactor

valid jetty
#

we may be getting a longer identifier cap in qbe

placid cape
#

yey

valid jetty
#

put them into a static struct or something

#

?

placid cape
#

not sure but your compiler should be separated into multiple files

placid cape
valid jetty
#

this allocator thing actually doesnt add very much to the compiler itself

placid cape
#

okay im gonna implement unary operators

#

this is my compiler structure rn

#

compiler.go:

package compiler

import (
    "blom/ast"
    "blom/compiler/qbe"
)

type Backend int

const (
    QBE Backend = iota
    LLVM
)

type Compiler struct {
    Backend Backend
}

func New(backend Backend) *Compiler {
    return &Compiler{Backend: backend}
}

func (c *Compiler) Compile(program *ast.Program) string {
    switch c.Backend {
    case QBE:
        return c.compileQBE(program)
    case LLVM:
        return c.compileLLVM()
    }

    panic("Unknown backend")
}

func (c *Compiler) compileQBE(program *ast.Program) string {
    qbeCompiler := qbe.New()
    qbeCompiler.Compile(program)

    return qbeCompiler.Emit()
}

func (c *Compiler) compileLLVM() string {
    panic("Not implemented")
}
valid jetty
#

interesting

placid cape
#

and ill do something similar with transpilers

valid jetty
#

idk im a lot more focused on making progress than design choices even if its unreadable for now

#
AstNode::Environment { value, location } => {
    if let Some(value) = value {
        if !self
            .data_sections
            .iter()
            .find(|data| data.name == ENV_ID)
            .is_some()
        {
            self.data_sections.push(Data {
                linkage: Linkage::public(),
                name: ENV_ID.into(),
                align: None,
                items: vec![(Type::Long, DataItem::Const(0))],
            })
        }

        let (ty, val) =
            self.generate_statement(func, module, *value, ty, None, is_return)
                .expect(&location.error(
                    "Unexpected error when compiling value to set to environment",
                ));

        func.borrow_mut().add_instruction(Instruction::Store(
            ty.clone(),
            Value::Global(ENV_ID.into()),
            val.clone(),
        ));

        Some((ty, val))
    } else {
        let ty = Type::Pointer(Box::new(Type::Struct(ENV_STRUCT_NAME.into())));
        let val = self.new_temporary(None, false);

        func.borrow_mut().assign_instruction(
            &val,
            &ty,
            Instruction::Load(ty.clone(), Value::Global(ENV_ID.into())),
        );

        Some((ty, val))
    }
}
``` this thing is silly
placid cape
#

and probably ill make same sort of abstraction like i did for qbe for other langs as well

#

like js, lua, py

valid jetty
#

you wanna transpile to py??

placid cape
#

but first i want working compiler

placid cape
#

and my goal is to make the transpiler actually transpiles into readable code

#

and not some unreadable nonsense

#

but compiler is the highest priority rn

crimson sparrow
placid cape
#

@valid jetty why you dont have unaryoperation and instead you have everything in literal with tokenkind unary except bitwise not

#

thats extremely weird

crimson sparrow
#

I love the idea of spending time writing good code for it to then be turned into garbage

#

You can even call it python interop :)

valid jetty
#

theres a lot of bad decisions in the compiler

placid cape
#

well thats parser but yeah

valid jetty
#

in the.. project?

#

idk what to call the whole collection of things

#

the language

#

the toolchain

#

the infrastructure

#

๐Ÿ˜ญ

#

so many modules

#

ok well all the tests pass

#

commitey commitey

#

actually i have to fix the docs

#

argc and argv arent a thing anymore

placid cape
valid jetty
#

oh actually

#

i love that args is a string[] now

#

not only is it iterable but you can use it like any other array

placid cape
#

for this:

valid jetty
#
use std/prelude;

fn main(string[] args) {
    let program = args.remove(0);

    for arg in args {
        if arg == "foo" {
            io::dbg("i received a foo!");
        }
    }
}```
placid cape
valid jetty
#

yeah that looks about right

#

unary should definitely be just a generalized node

#

but im silly so

placid cape
#

your ast is this

valid jetty
#

thats not the updated ellec

placid cape
#

yea i know

#

its older

valid jetty
#

theyre called Literal and BinaryOperation but yeah same thing

placid cape
#

but you just renamed the names

valid jetty
#

yeah

placid cape
#

yea i have elle cloned so i can easily check QBE :D

#

assignment is not threated as expression, must fix it

#

i should implement != lol

#

the compiler is so much cleaner now

#

thanks to the qbe abstraction

#

@valid jetty really thx

calm ruin
#

wth is wrong with ios jailbrekers ๐Ÿ˜ญ

#

why is there redis server

#

why would you host redis server on your iphone

placid cape
#

xD

valid jetty
placid cape
#

this for example

valid jetty
#

oh lol i see

#

im sure there are many issues with this

#

but there are no more memory leaks at last

#

and its actually faster than it was before

#

the best part is for most small programs it can manage the whole program runtime in a single 64kb arena lol

#

this isnt ideal because if the program runs for a while itll still allocate a lot of memory (it only frees at the end) but its at least better than literally leaking it all

#

and allocation now is way faster if youre allocating often and in small chunks

placid cape
#

yuhuuu if ipmplemented

#

i can again calculate fibonacci number :D

valid jetty
#

yay!!

#

do you have a plan for dynamic memory management yet?

placid cape
#

nah

valid jetty
#

you will malloc everywhere and leak it all

placid cape
#

i must improve my parser and analyzer

#

then i can work on stuff like that

#

and probably import system before dynamic memory management

#

okay if done, while loop next

#

its because i made changes in AST and used a simple hack in parser instead of actually changing parser

#

if then, else is not threated as blockstatement anymore but as a list of statements

valid jetty
#

lmfaooo

#

@hoary sluice

placid cape
hoary sluice
#

or just dont do frontend

#

let someone else do it

valid jetty
#

if i ever get a frontend job i have 1 million ideas for how i could keep that job

calm ruin
#

@valid jetty rosie

hoary sluice
valid jetty
#

lmao

hoary sluice
#

@calm ruin arent you a pascalcase user

valid jetty
#

@calm ruin @calm ruin string methods no longer leak memory

#

calling string.concat no longer leaks 24 bytes each time

hoary sluice
#

@calm ruin @calm ruin strings exist in the lexer now

valid jetty
#

whats a lexer

placid cape
#

@calm ruin new compiler arrived

hoary sluice
#

lexer sounds so weird to say

placid cape
hoary sluice
valid jetty
#

technically it should be called tokenizer if you wanna use the naming convention of tokens

valid jetty
#

otherwise tokens should be called lexemes

valid jetty
#

yes thats a real word

placid cape
#

and go is not a bad language

calm ruin
#

I use whatever I want

hoary sluice
# valid jetty

it does lexical analysis of a string and returns it in parser-readable tokens

placid cape
calm ruin
#

but mostly camelcase

#

and snake case in json

hoary sluice
#

use rAN-Do__mCAs-_e

calm ruin
#

and upper snake on static variables

calm ruin
frosty obsidian
hoary sluice
#

icps will enforce a strict no uppercase letters policy

valid jetty
# hoary sluice did u finally bother to start freeing

no i wrote a whole arena allocator and setup an env system where a pointer to an env struct is stored in static memory then allocations all go through the arena allocator instead of malloc and are freed at the end (#env.allocator.alloc is abstracted from the developer, they just use it, its up to the compiler to determine which allocator structure to put into #env.allocator)

valid jetty
#

thats literally the whole point of what ive been talking about for the past 2 days lol

placid cape
#

yee

#

great job

frosty obsidian
#

basically just don't store dates like americans

valid jetty
#

basically allocate things in chunks

placid cape
#

i still hate windows that it stores time in specific timezone instead utc

calm ruin
#

malloc(10239120391);

placid cape
#

so you cant have different timezones on different accounts lol

hoary sluice
calm ruin
#

/run

int main() {
int *e = malloc(123912381223323);
*e = "aagaming";
printf("%s", e);
}
rugged berryBOT
#

@calm ruin I received c(10.2.0) compile errors

file0.code.c: In function 'main':
file0.code.c:2:10: warning: implicit declaration of function 'malloc' [-Wimplicit-function-declaration]
    2 | int *e = malloc(123912381223323);
      |          ^~~~~~
file0.code.c:2:10: warning: incompatible implicit declaration of built-in function 'malloc'
file0.code.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'malloc'
  +++ |+#include <stdlib.h>
    1 | int main() {
file0.code.c:3:4: warning: assignment to 'int' from 'char *' makes integer from pointer without a cast [-Wint-conversion]
    3 | *e = "aagaming";
      |    ^
file0.code.c:4:1: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
    4 | printf("%s", e);
      | ^~~~~~
file0.code.c:4:1: warning: incompatible implicit declaration of built-in function 'printf'
file0.code.c:1:1: note: include '<stdio.h>' or provide a declaration of 'printf'
  +++ |+#include <stdio.h>
    1 | int main() {
/piston/packages/gcc/10.2.0/run: line 6: 593183 Segmentation fault      (core dumped) ./a.out "$@"
frosty obsidian
#

i mean for storing

#

which was that guys problem

hoary sluice
#

they probably just use date objects

frosty obsidian
#

they didn't

#

they stored them in the american format

hoary sluice
#

maybe they were reading incorrectly from the user

valid jetty
# hoary sluice idk what an arena is

if you wanna allocate a bunch of 4 byte structs theres no point to do a seperate dynamic allocation for each one (thats slow), just allocate one big region of 64kb (the current size of an arena) and store it all in there

if allocating something exceeds the size of an arena just create a new arena and keep them all linked via a linked list

which also makes it very easy to free all the memory at the end because you just free all the arenas in the linked list chain

hoary sluice
#

american instead of normal

frosty obsidian
#

which fails to parse bc of different regions

#

they should have just used one of the two standards

hoary sluice
valid jetty
#

and this is abstracted from the user so i can easily swap it out to something else like a bump allocator or garbage collected allocator or direct heap allocator you just switch what structure is put into #env.allocator in the compiler

calm ruin
#

@valid jetty add function to elle which is randomem, it will return random memory adress for you to write

valid jetty
calm ruin
#

so you can nuke your program accidently

odd lake
#

you don't need to check the entire region every time

hoary sluice
valid jetty
#

something like this

struct Foo {
    void *a;
    void *b;
    void *c;
    void *d;
};

fn Foo::new() {
    Foo *foo = #env.allocator.alloc(#size(Foo *));
    *foo = #env.allocator.alloc(#size(Foo));

    foo.a = foo.b = foo.c = 0;
    return foo;
}

for i in 0..100 {
    let foo = Foo::new();
    io::dbg(foo);
}
hoary sluice
#

i thought u needed to traverse each chunk

valid jetty
#

if #env.allocator.alloc is set to just called malloc each time, thats really slow

#

instead its set to just give you a chunk out of a 64kb page of the size you request

#

if there isnt enough space left it makes a new 64kb region and gives you memory from that

#

and then links it to the old one with a linked list

#

you never search anything because you just hold a pointer

#

the only time you would ever need to search the linked list is for a freelist realloc thing but i didnt implement that, realloc just allocates new memory and copies the buffer into it

hoary sluice
valid jetty
#

no lol

#

its like a pool

#

everything is allocated into the 64kb

#

at the end you just traverse the linked list of arenas and free each one

hoary sluice
#

ur just preallocating 64kb

valid jetty
#

not exactly

#

if you need more than 64kb it allocates another 64kb and links them together

hoary sluice
#

and then you have another 64kb preallocated

valid jetty
#

if the memory allocation you want is more than 64kb (the size of an arena) it makes a custom arena with specifically that size youre requesting (aligned to 8 bytes)

valid jetty
#

for example my day 12 solution allocates 812 arenas iirc

hoary sluice
#

that sounds awesome

valid jetty
#

it is lol

#

the only issue is it doesnt free the arenas until the program finishes

hoary sluice
#

good thing im not gonna have to do it any time soon

valid jetty
#

ideally this thing would be linked to a garbage collector to free allocations that arent used anymore

hoary sluice
#

whens the elle borrow checker update dropping

valid jetty
#

borrow checking sounds so easy on paper but so hard to actually write

hoary sluice
#

it sounds hard on paper

valid jetty
#

you need to know so many intrinsics about a program at compile time

#

rust has the MIR (pre-ir) for analyzing and enforcing borrow checking rules lol

valid jetty
hoary sluice
#

man i really hope the performance of the interpreter will be bearable so i dont have to do any of this shit

valid jetty
#

you dont really need to do any of this

#

you can get away with literally leaking all dynamic memory with malloc

#

the system will go and release it when a program finishes execution anyway

#

i did that for the longest time and it worked fine

hoary sluice
#

ah yes the pretend garbage collector

valid jetty
#

yeah well

#

it worked

hoary sluice
#

man tsoding is not real

#

when i first heard of him i thought it was a misspelling of tscoding and didnt check who he was cause i thought hes another ts codefluencer

valid jetty
#

would you rather

for x in [39, 40, 41] {
    io::dbg(x);
}

or

let arr = [39, 40, 41];
defer arr.free();

for x in arr {
    let str = io::dbg(x);
    mem::free(str);
}
valid jetty
#

not romantically

hoary sluice
#

bro did aoc 2021 visualizations in fucking holyc

valid jetty
#

where is that stream

#

i remember it

#

link required !!

hoary sluice
#

gn

hoary sluice
valid jetty
#

wtf

#

its only 11pm

#

how are you maintaining a sane sleep schedule during a holiday

#

i literally stayed up to 6am last night

hoary sluice
#

i was sleeping at 6:30pm during aoc