#🪅-progaming

1 messages · Page 85 of 1

winged mantle
#

why husk

#

...

deep mulch
#

not allowed

#

kode tode

#

the kode of tode

winged mantle
#

when i said infix operators are clean i didn't mean i actually like them

#

i think languages should be more simple than that

deep mulch
#

yes

#

I think we should make a language with no words

deep mulch
#

@winged mantle use

winged mantle
#

c is the perfect language

#

🌊

shrewd canopy
#

What about Rust

winged mantle
#

pretty good in a practical sense

#

but it has too many features to be perfect

#

c has far too few features, so it's perfect

#

i mean in a "the perfect IDE is notepad kind of way"

fleet cedar
#

C does not have enums or traits

#

So it cannot possibly be perfect

winged mantle
#

c has enums

#

how they should be

fleet cedar
#

C has named constants

winged mantle
#

named constants

fleet cedar
#

I prefer useful things myself

winged mantle
#

i mean rust enums are a hybrid of enums and variants

#

or ig just named variants

fleet cedar
#

Sum types are an indispensable feature whether you call them enums or something else

winged mantle
#

named constants are perfectly useful as... normal enums

fleet cedar
#

They're usable as named constants, barely

winged mantle
#

well... for the purpose of just storing a set of static things they're ok enough

#

java style enums where you can attach data do make them a little nicer i guess

#

rust's solution is even more powerful, it's just I think it goes beyond what an enum traditionally needs to do

#

I guess this is an example where c enums can feel limited

public enum Color {
    RED(0xFF0000), GREEN(0x00FF00), BLUE(0x0000FF);

    Color(int hex) { this.hex = hex; } 
    public int hex;
}

but does rust really have this in the same way
don't you have to do match self

#

which is basically like c so 🤷

winged mantle
#

imagine if you're de/serialising something to binary

#

it's useful that enums are just numbers and you can write them directly as a byte blobcatcozy

valid jetty
#

you can do that in rust tho

#

like noone is stopping you from doing this

#

named constants

winged mantle
#

horror

valid jetty
#

you can even make them more named by making their names unqualified

deep mulch
valid jetty
deep mulch
#

@valid jetty hii

valid jetty
#

hii

winged mantle
#
enum Color {
    RED, GREEN, BLUE
}

int color_value(Color color) {
    switch (color) {
        case RED: return 0xFF0000;
        case GREEN: return 0x00FF00;
        case BLUE: return 0x0000FF;
    }
}
#

this is what i was going for

valid jetty
#

who says you cant do that in rust tho 😭

winged mantle
#

it's basically the same thing though that's why i don't think c is much worse for using enums as constants

deep mulch
#

ulgy

valid jetty
#
enum Color {
    RED, GREEN, BLUE
}

use Color::*;

fn color_value(color: Color) -> i32 {
    match color {
        RED => 0xFF0000,
        GREEN => 0x00FF00,
        BLUE => 0x0000FF
    }
}
fleet cedar
#

C enums have no type safety and can not carry data

#

They are inferior

valid jetty
#

equivalent to your C code

#

though in any real codebase you would use the qualified names for the enum variants

#

use Color::* is cursed

winged mantle
#

but if you were doing it in a more rusty way wouldn't it be virtually the same too

#

that's what i mean

valid jetty
#

wha

valid jetty
#

default: UNREACHABLE

#

lmao

glacial mirage
#

just make them constants smh

valid jetty
#

i mean yeah i guess

winged mantle
# valid jetty wha

i mean like, i don't think this does much to make the c version cleaner

enum Color {
    Red, Green, Blue
}

impl Color {
    fn value(self) {
        match self {
            Red => 0xFF0000,
            Green => 0x00FF00,
            Blue => 0x0000FF
        }
    }
}
#

you are still doing a switch

#

i don't think you can do the same thing you can do in java

valid jetty
#

@fleet cedar is there a way i can impl PartialEq only for a specific variant of an enum otherwise call the derived Eq method???

#

without a wrapper or helper type because i dont want all of that boilerplate and implementing a proc macro for converting to it is also kinda annoying

valid jetty
#

C lets you do this too, why not use it

winged mantle
#

but i mean sometimes you might want multiple different types of data

valid jetty
#

in which case rust wins because it has tagged unions i guess

glacial mirage
#

mine can be literally any type of data lololol

valid jetty
#

but i mean even in C

enum ThingKind {
    STRING, INT
};

struct Thing {
    enum ThingKind tag;
    union {
        int i;
        char *s;
    } value;
};

struct Thing Thing_new(enum ThingKind tag, void *value) {
    switch tag {
        case INT: return (Thing) {
            .tag = tag,
            .value.i = *(int *)value
        }
        case STRING: return (Thing) {
            .tag = tag,
            .value.s = *(char **)value
        }
        default: UNREACHABLE; break;
    }
}
#

you dont have type safety

#

but youre literally working in C

deep mulch
#

@valid jetty you

#

unhusk

lavish frigate
#

95% of rust criticism is just "why is rust not (other language)"

#

"but what if i want to do it like this way like i do in (other language)"
"why not do it (better way)"
"but i wanna do it the shitty way like (other language)"

valid jetty
#

idk i if i particularly like this error message

#

maybe i can print them specially if theyre a lambda so it doesnt show that ugly ::23123 thing

deep mulch
valid jetty
#

i can make it do that

winged mantle
#

can i open pr to elle adding 🖨️ operator

fleet cedar
#

Only if you add emojis for other operators too

winged mantle
lavish frigate
#

can i open pr to elle adding <?elle and ?> to allow for embedding elle inside html

fleet cedar
#

Why not embedding elle inside elle

winged mantle
#

something actually really annoying though is needing to keep variables out of scope before doing await

valid jetty
#
fn main() {
    x := "fn main() {
    x := \"?\";
    io::puts(x.replace(#[63], x.replace(#['\\\\', '\\\\'], #['\\\\', '\\\\', '\\\\', '\\\\']).replace(#['\"'], #['\\\\', '\"'])));
}";
    io::puts(x.replace(#[63], x.replace(#['\\', '\\'], #['\\', '\\', '\\', '\\']).replace(#['"'], #['\\', '"'])));
}
``` the
fleet cedar
#

No just <?elle ?>

valid jetty
#

what does that mean

deep mulch
#

the

valid jetty
fleet cedar
valid jetty
#

if you run that program it will print itself

deep mulch
#

oh

deep mulch
#

@valid jetty rosinga

winged mantle
#

i just ended up not implementing something and decided rust has to not fully be turing complete otherwise i would've been able to do it

#

i love how c has a header called ctype

#

do you do cctype in c++

lavish frigate
#

you use the header within rust and then type your typeless rust

winged mantle
#

i wanted to add a fallback to requesting the channel from discord's api if it's not cached (for closed threads) and I can't even comprehend how you do that
it needs to be in the if block, and if you await inside the if block it gives an error

#

😭

lavish frigate
#

serenity 😨

winged mantle
#

ignore the fact it does linear search that isn ecessary in the stable and current verersion

#

but fixed in next

#

i think i would need to move it out of that if block and instead do a check that the cache contains it without storing it in a var

#

so it would need to be duplicated...

#

i also wanted to use /discovery/{guild_id} route to look up server if the bot is not in it

#

but serenity's request handler requires passing in an enum for the route and it's not defined rip

#

(i think it's undocumented)

#

(it's used by @pearl stag)

valid jetty
#

i might try adding this @deep mulch

[1, 2, 3].map(fn(x) x * 2);
```right now you have to specify that x = i32, but it can be inferred
shrewd canopy
valid jetty
#

the working version atm is

[1, 2, 3].map(fn(i32 x) x * 2);
deep mulch
#

@valid jetty what about .map { x -> x * 2 }

#

or similar

valid jetty
#

zoot only thinks in kotlin

deep mulch
#

yes

shrewd canopy
#

I only think in python

winged mantle
#

thanks though

valid jetty
#

map(lambda x: x * 2, [1, 2, 3])

winged mantle
#

are these documented

deep mulch
#

why is the lambda first

valid jetty
#

tbh idk

shrewd canopy
deep mulch
#

map(fn(x)) { x * 2 }

shrewd canopy
deep mulch
#

map(Function x = {x * 2})

winged mantle
#

i am dumb

#

wait no

valid jetty
#

@deep mulch should i add a then function on every type

deep mulch
#

what would it do

winged mantle
#

i want it to happen in the case where the guild is cached, but it can't be found

#

if the guild isn't cached, it shouldn't bother

#

and rustc will complain that the future is not Send or something

deep mulch
#

@valid jetty pipe operator would be good

valid jetty
#
3941123
  .then(fn(a) a + 1)
  .then(i32::to_string)
  .then(fn(a) a.split(""))
  .then(fn(a) c - '0')
  .then($println);
#

yeah thats basically pipe

deep mulch
#

hm

winged mantle
#

horror

deep mulch
#

probably not then but using |> yes

#

more readable

valid jetty
#
3941123
  |> $ + 1
  |> i32::to_string
  |> $.split(""))
  |> $ - '0'
  |> $println;
winged mantle
#

do 3941123 | $ + 1 | $.toString() | $.split("") | $ - '0' | println($)

deep mulch
#

Rosie loves $ everywhere

winged mantle
#

wait i ahd the same idea to do $

valid jetty
#

$ is actually common in cases like this

winged mantle
#

is this what functional langs normally do

valid jetty
#

yea

#

or well

winged mantle
#

lol that surprised me

valid jetty
#

pipe operator usually has $ for "this value"

#

its a common thing

deep mulch
#

id prefer it

winged mantle
#

i was just trying to think of bash

deep mulch
#

$ is overused in elle

winged mantle
#

and i know it uses $ in a lot of places

winged mantle
valid jetty
deep mulch
#

I hate groovy

#

it sucks

deep mulch
winged mantle
#

it's fiine

#

i don';t blame you for loving groovy

deep mulch
#

$(2, 3)

valid jetty
#

tuples are also an stdlib alias

#

$ is an alias for Tuple::new

deep mulch
#

😭

#

hatred

#

I hate that

#

map(x |> fn(x) x * 2 |> fn(x) x + 1)
or
map(x |> x * 2 |> x + 1)

#

though you'd just use all the operators together in that specific example

winged mantle
#

add support for running sh

#

what was that bun api

valid jetty
winged mantle
#

where you could do something like sh`cd ${dirname}`

glacial mirage
#
3941123
  |> add(_, 1)
  |> i32::to_string
  |> split(_, "")
  |> sub(_, '0')
  |> println;
#

bad

winged mantle
#

what's the point of piping anyway

#

let $ = 33941123

#

$ += 1

valid jetty
#

there is none

glacial mirage
#

syntax sugar idk

winged mantle
#

sericreatur I don't understand why kotlin has it

glacial mirage
#

better than 500 layers of brackets

winged mantle
#

abusable

winged mantle
#

it has .let

#

and stuff

deep mulch
#

scope functions

#

they're different

glacial mirage
#
println((3941123 + 1).to_string().split("") - '0')
#

this case is kinda dumb because theres no actual foo($) methods

#

something like turning foo(bar(baz(qux))) into qux |> baz |> bar |> foo makes sense

winged mantle
#

add support for currency

#

$0

#

let price: $int = $0

#

let price: $float = $1.40

deep mulch
#

insane

glacial mirage
#

$0 obviously means first arg smh

winged mantle
#

every programming language should copy node.js and have 2 as the first arg

#

(process.argv[2])

glacial mirage
#

let args = process.argv.slice(2)

valid jetty
#

it gives you all the arguments from execvp

winged mantle
#

with node it is
node script_name <args>

valid jetty
#

the 0th argument is always the executable

#

the 1st is therefore the script name

#

so yeah, logically the actual args you want start at 2

winged mantle
#

yeah so to get the actual args it's argv[2]

#

what's your point

valid jetty
#

idk

winged mantle
valid jetty
#

in a systems language they start at 1

deep mulch
#

@valid jetty wyd

valid jetty
deep mulch
#

o

#

is it hard

winged mantle
#

i am glad to have learnt that the first arg can't be relied on in c

valid jetty
#

i have access to the context type when compiling a function call

#

if you do foo(???), when compiling the ??? you know what foo expects that argument's type to be

#

as functions have strong types in the type system now, i can just use the callback's explicit types and backpatch untyped things to that type

deep mulch
#

what's ???

valid jetty
#

any expression

#
fn foo(fn(i32, string) x) { ... }

fn main() {
    // when compiling `fn(x, y) x` the compiler knows `foo` expects `fn(i32, string)`
    //  at that place in the call (in this case 0th arg), so we can just extract the
    // `i32` and `string and give them to `x` and `y`
    foo(fn(x, y) x); 
}
#

its not that hard

deep mulch
#

easy for a Rosie to say

lavish frigate
#

nvim is done for

deep mulch
#

We all edit

valid jetty
#

i dont edit

#

EXPLODE

#

oh

royal nymph
lavish frigate
royal nymph
#

why would anyone use this over nano / micro

lavish frigate
#

its because there is no pre-installed tui editor on windows

#

so youd have to go out of your way to install nano/micro

royal nymph
#

oh is that gonna be inbuilt

lavish frigate
#

yes

royal nymph
#

that's useful I guess

median root
#

nooooo not my neovim

lavish frigate
#

also its open source so thats always fun

#

(open source app made by microsoft!!! crazy)

median root
royal nymph
#

made by a german so you know it's good

median root
#

its like they do everything they can to make windows bigger

#

oh yeah is there a discord tui app that wont get me banned for api spam? i really wanna move discord over to the terminal

lavish frigate
median root
#

with neovim keybindings

lavish frigate
median root
#

a tui editor

#

the 3 hour update for a tui editor

#

oh yippie

lavish frigate
#

you are not the target audience for this

median root
#

yeah i know

#

never used a windows system in my life lol

placid cape
#

Awesome gjjj

shrewd canopy
lavish frigate
#

weird ahh payloads

shrewd canopy
#

sure (missing bunch of properties, and nonce when sending a message)

valid jetty
#

@deep mulch FINALLY

#

THAT TOOK SO MUCH LONGER THAN I EXPECTED

deep mulch
valid jetty
#

literally can call mapping functions with no specifying of types anywhere

#

it infers everything

#

even the type of x

lucid trail
#

type inference is so cool

#

are you doing some specific algorithm like algorithm W or just figuring it out

valid jetty
#

from scratch

#

i prefer to do it myself if i can

#

i learn more that way

deep mulch
#

I couldn't do it myself

#

it would take me hundreds of years

lucid trail
#

i finished my first C project! a tiny stack based programming language (shown is 39th fibonacci number)

#

conclusion is i can't live without tagged unions and C is really annoying

#

and this is 16!

valid jetty
#

nice :3

#

the syntax looks so silly lol

lucid trail
valid jetty
#

true

#

is this interpreted

#

actually

lucid trail
valid jetty
#

interesting that you chose duplicate lmao

#

would get annoying to type a lot

lucid trail
#

i didn't think about the syntax a lot

#

the lexing is also pretty inconsistent with whitespacing

winged mantle
#

another language i have to stop myself from giving "helpful" suggestions for

winged mantle
fleet cedar
winged mantle
#

nahh i feel impressed that rosie has not blocked me yet

#

i suggested jsx support

#

and a 🖨️ operator

deep mulch
#

@valid jetty is Elle your first language youre developing

valid jetty
#

im here to have fun

#

im not doing serious development

winged mantle
#

i feel i might be a tiny bit annoying somtimes

#

:3

valid jetty
#

nop

lucid trail
fleet cedar
#

Doesn't stop me

valid jetty
#

TRUE

winged mantle
#

true i should add you

#

i like annoying people

lucid trail
valid jetty
#

not that youre annoying but

#

that you can be annoying without caring

#

i love being annoying and not caring about it

deep mulch
#

Rosie continues to impress me with sheer geniusness

valid jetty
#

ive been working on this for like all of my free time all day every day for over a year atp if i didnt have progress it would be concerning

deep mulch
#

how do you have so much motivation

valid jetty
#

its fun

#

seeing things work

deep mulch
#

I find things fun and still lose motivation

winged mantle
#

make kotlin object notation

deep mulch
#

never

valid jetty
#

wdym

#

whats kotlin object notation

winged mantle
#

like my jon idea

deep mulch
#

john

winged mantle
#

parse syntax like

new Map() {{ put("key", "value"); }}
that would be so fire
wait can you do Map.of

valid jetty
#

jonathan blow

winged mantle
#

do same thing but however you do it in kotlin

#

is it like mapOf {
"cheese" to "burger"
}

#

i can't remember

deep mulch
#

close

#

mapOf("cheese" to "burger")

winged mantle
#

kotLin

valid jetty
#
HashMap::with_entries("cheese", "buffer");
``` !!!
winged mantle
#

cheese buffer

valid jetty
#

HOW DID I TYPE BUFFER

winged mantle
#

i bet you say in your whatsapp group yes i would like a cheese buffer

lucid trail
#

ches buffer

deep mulch
#

buffer

winged mantle
#

and your non programmer friends are confused

valid jetty
#

no 😭 i accidentally typed buffer

#

like muscle memory

winged mantle
#

i said to non programmer friends byte instead of bye before

lucid trail
#

meson for building C has been so good for me

#
# meson.build
project('cazal', 'c')

src_files = run_command('sh', '-c', 'ls src/*.c', check: true).stdout().strip().split('\n')

executable('cazal', 
  src_files,
  include_directories: include_directories('src')
)
deep mulch
#

meson is nice I just wish the docs were better and better ide support

valid jetty
#

why is there rust syntax

#

.stdout().strip().split('\n')

#

out of nowhere lol

fleet cedar
#

How is that any more rust than any other language

lucid trail
#

gotta love my DSL for build systems

valid jetty
#

i know i was kidding

winged mantle
#

rust brainrot

deep mulch
#

Elle is the rustiest

winged mantle
#

zoot uses build.gradle.kts for C++

deep mulch
#

nop

valid jetty
#

zoot uses build.zig

deep mulch
#

Gradle C++ is too basic

#

nop

#

no good documentation

winged mantle
#

cmake has something to build java

deep mulch
#

yop

valid jetty
#

every project is well documented if you can read source code

valid jetty
#

i take it back

winged mantle
#

i should do more code golf

deep mulch
#

@valid jetty

valid jetty
#

omg this still doesnt work if you try to access methods on the type in the cb

#

i think i know how youre meant to do it

#

or well

hoary sluice
#

@valid jetty compile elle to malbolge

valid jetty
#

a way that would work

lucid trail
winged mantle
deep mulch
#

@valid jetty tomorrow you will get your first job

#

I got my first job at 16 or 17 @valid jetty

winged mantle
#

horror

lucid trail
#

i'm gonna have to get a job in almost 1 year exactly

#

horror

winged mantle
#

how do you know you will get a job in almost 1 year excatly

lucid trail
#

oh i don't know if I will, i just have to

winged mantle
#

i dunno what i wanna have a job doing

#

it will probably be something i never expected

#

(which is exactly the thing i expected because i don't expect it)

valid jetty
#

my goal is to compile

fn foo<T, U>(T x, fn(T) -> U y) {
    y(x);
}

fn main() {
    foo(3, fn(x) x * 2);
}

during monomorphization:

  • compile lambda once but only arguments, not the body, dont add the function, this gives me the link between the args and the generics
  • compile again but this time, knowing the arguments, dont add the function, but compile including the body so you can get the generic for the return type
  • compile last time knowing all generics and add the function
#

this is actually a complicated problem

#

because if you naively just compile twice, you end up not knowing T in one of the passes

deep mulch
#

Rosie will omit fn for passing in functions

valid jetty
#

(x) x * 2 is ambiguous

deep mulch
#

I mean in the function signature

#

the -> implies it's a function

valid jetty
#

a function that takes T and U and returns void without fn would look like (T, U) which looks like a tuple

valid jetty
deep mulch
#

hm

#

true

#

can be solved with type proceeding the argument name

valid jetty
#

that syntax is really unreadable though

lucid trail
valid jetty
#
fn foo<T, U>(T x, U(T)) {
    y(x);
}
deep mulch
#

wait

#

nvm

deep mulch
deep mulch
valid jetty
#

wha

lavish frigate
#

php is best lang cuz ` stands for shell exec

#

/run

<?php

echo `ls`;
rugged berryBOT
#

Here is your php(8.2.3) output @lavish frigate

file0.code
lavish frigate
#

/run

ls
rugged berryBOT
#

Here is your bash(5.2.0) output @lavish frigate

file0.code
deep mulch
#
fn foo<T, U>(x: T, y: (T) -> U) {
    y(x);
}
lavish frigate
#

🔥 ?

deep mulch
#

it wouldn't work anyways

#

you'd still have to specify void

#

wait

#

actually

#

nvm

#

idk

deep mulch
#

nop

#

@valid jetty continue with what you have

#

I stil think argument name preceding type is more natural to read

valid jetty
#

i like rhs idk

#

its rhs in structs too

#

but putting them on the left does not solve the problem at all lol

winged mantle
#

rhs?

#

right hand side of what?

lucid trail
#

Arg name right of type im guessing

winged mantle
#

is it good practice to do this in a .c file blobcatcozy
so that you can override with compiler args

winged mantle
#

(i am implementing a growing string 😭)

#

my library uses malloc

#

is that bad

deep mulch
#

how

#

@winged mantle make tode alloc

winged mantle
#

talloc

deep mulch
#

@valid jetty hiii

valid jetty
deep mulch
#

@valid jetty Elle for embed

#

Guhhh rewrite qbe in elle

winged mantle
#

for the sake of learning i should probably make this library work on a wide variety of platforms

#

*for the sake of pain

lucid trail
#

i have so much rust brain rot

lavish frigate
#

you dont have enough

winged mantle
#

i am coding using sublime text

#

no lsp

#

no errors or autocomplete

#

(you can probably set it up but who needs that)

lucid trail
#

i can’t live without go to definition (it’s like marginally faster than grepping it)

winged mantle
#

i use grep all the time to find definitions

winged mantle
#

most kodepilled setup

valid jetty
winged mantle
#

you love

#

i renamed macro

#

honetly i think sublime is the best minimal text editor

#

it feels very performant

#

did zed really do anything groundbreaking

deep mulch
#

@winged mantle uses edit

lucid trail
deep mulch
winged mantle
#

use ed

winged mantle
winged mantle
valid jetty
winged mantle
#

We all edit.

#

so corporate

deep mulch
#

We all Elle.

winged mantle
#

remember when microsoft open sources something it's because they determine that it is commercially viable

#

uncle bob level clean code right here

#

is it kinda awkward that you need to do builder = string_builder_append(builder, "obama")

#

it wouldn't be hard to make it just string_builder_append(builder, "obama") or string_builder_append(&builder, "obama") but the former would be less efficient and the latter would mean you could accidentally make unsafe copies

valid jetty
#

the latter is how i typically see that kind of api

#

not sure why youre not going with it

#

hm

#

what do you mean

winged mantle
#

how well do you know c

#

you can't override how things are copied

valid jetty
#

oh i know what you mean i think

winged mantle
#

the fact you do &builder implies that you builder would not already be a pointer and would be on stack

#

oh wait

#

i am dumb anyway

valid jetty
#

surely you can just take a pointer

winged mantle
#

because with reallocing the builder it would be unsafe anyway

valid jetty
#

why does it matter if its on the stack

#

uhh yeah that too

#

you should be reallocing the buffer

deep mulch
#

@valid jetty you smell like flowers

winged mantle
#

yea...

fleet cedar
deep mulch
#

Rosie rot

fleet cedar
#

And then the functions take a strbuilder*

winged mantle
#

well

#

ew

deep mulch
#

@valid jetty does Elle have proper heap and stack

winged mantle
#

@deep mulch throws u on the heap

deep mulch
#

I forgot which one is which

#

stacks the faster one right

fleet cedar
#

A stack is lifo while a heap can access smallest only

winged mantle
#

heap is dynamic

valid jetty
#
void string_builder_append(StringBuilder *builder, char *str) {
    int old_length = builder->length;
    builder->length += strlen(str);

    if (builder->length >= builder->capacity) {
        while (builder->length >= builder->capacity) builder->capacity *= 2;
        builder->buffer = realloc(builder->buffer, builder->capacity);
    }

    memcpy(builder->buffer + old_length, str, strlen(str));
}
``` surely its just this @winged mantle
#

am i missing something

winged mantle
#

stop helping me 😤

#

smh

#

(yes)

valid jetty
#
int main() {
    StringBuilder builder = {0};
    string_builder_append(&builder, "wow");
}
#

silly

winged mantle
#

wait it shouldn't be >=

valid jetty
#

it should

#

if the buffer is full it will reallocate the next time you push something

#

might aswell grow now

winged mantle
#

might as well start of as 1gb

#

i don't think it really makes a difference? apart from being slightly less memory efficient?

valid jetty
#

what, >=?

#

it doesnt really matter yeah

winged mantle
#

say you append exactly 16 bytes

#

then it's nice and snug

valid jetty
#

i guess so

fleet cedar
#

I think people would be upset if ```c
StringBuilder builder = StringBuilder::with_capacity(4);
builder.append("four");

winged mantle
#

and how would it make anything more efficient?

valid jetty
#

lmao fair

valid jetty
winged mantle
#

ig i will make string_builder header only

#

idk or is that bad idea

valid jetty
#

youre just doing the growing logic right now instead of offloading it to the next push

valid jetty
#

do you know how to do both in the same file

#

with #define STRING_BUILDER_IMPLEMENTATION and whatever

winged mantle
#

if you implement in header doesn't that mean it either has to be static or inline

valid jetty
#

nope

#

you can put any arbitrary C code in header files

winged mantle
#

oh wait

valid jetty
#

its just a different file extension but its still just C code

winged mantle
#

i just rememberewd i needed guards

#

but can't you get odr violations or something

valid jetty
#

wha

winged mantle
#

The One Definition Rule (ODR) is an important rule of the C++ programming language that prescribes that classes/structs and non-inline functions cannot have more than one definition in the entire program and templates and types cannot have more than one definition by translation unit. It is defined in the ISO C++ Standard (ISO/IEC 14882) 2003, a...

#

seems like c ++ thing

fleet cedar
#

In C you'd just get duplicate definition errors

winged mantle
#

yeaa

valid jetty
#

yeah

winged mantle
#

don't you have to make static so everything that imports it gets its own copy?

valid jetty
#

not really no

#

not in C

winged mantle
#

why not?

winged mantle
#

yeah but... how does that prevent the fact that you're potentially defining the function multiple times?

valid jetty
#

include guards?

fleet cedar
#

If you put a normal function in a header and include it from two compilation units, you have now defined that function twice and will get a linker error

valid jetty
#

well i mean yeah obviously

#

hence include guards

fleet cedar
#

I said in different compilation units

valid jetty
#

well if this is a header only library, you would define the IMPLEMENTATION macro in one unit and not in the other one

winged mantle
# valid jetty include guards?

but each c file is gonna be compiled separately?
if while one c file is being compiled something is defined i don't think that affects other c files?

valid jetty
#

so the other one will only compile the headers

winged mantle
#

i believe the include guards are just to prevent multiple extern declarations

fleet cedar
#

So you mean make it not header-only at all, just the implementation is ifdef instead of a separate c file

#

That's gonna make things so much nicer to work with great job gold star for you ⭐

valid jetty
#

that is what header-only is though, the header and implementation in the same file

winged mantle
winged mantle
#

so you do need static or inline, right?

#

or is there another way?

fleet cedar
#

In c, yes

#

In c++, classes and templates are sorta exempt from ODR

winged mantle
#

i mean in c++ pretty sure things are implicitly made inline

fleet cedar
#

(You get a no-diagnostic ub if you violate it instead)

valid jetty
#
#ifdef STRING_BUILDER_IMPLEMENTATION
int foo(int x) {
    return x * 2;
}
#else
int foo(int x);
#endif
#define STRING_BUILDER_IMPLEMENTATION
#include "string_builder.h"

int main() {
    foo(3);
}
#include "string_builder.h"

int x() {
    foo(3);
}
``` surely no issues
#

or am i missing something

fleet cedar
#

That has exactly zero benefits compared to just putting the implementation in its own .c file

winged mantle
#

if that worked that would also mean if you included stdlib.h in one unit it would be available in another

#

oh wiait what

valid jetty
#

nothing's stb libraries work like this afaik

winged mantle
#

how could this possibly work

fleet cedar
#

git clone doesn't give a fuck if the repo contains one file or multiple

valid jetty
#

it doesnt, but if youre vendoring you dont git clone you just copy paste the file into your repo

fleet cedar
#

And if you're vendoring, you also do not care about whether you have multiple files

winged mantle
#

this wouldn't work, would it?

cc filea.c fileb.c

filea.c

#define A "aaaa"

fileb.c

#include <stdio.h>

int main() {
    puts(A);
}
fleet cedar
#

Not unless you #include <filea.c>, yes

winged mantle
fleet cedar
#

Compilation units are compiled separately

winged mantle
#

if you include the header in one unit... it's not gonna be defined... and if you include it in another it's gonna be defined either lol

#

ohh

valid jetty
#

no they share symbols in the end

#

the final object file

winged mantle
#

so you just do it only in the main file

valid jetty
#

yes

winged mantle
#

when you said include guard i thought you meant like pragma once

valid jetty
#

that is what i meant originally

winged mantle
#

that won't stop multiple implementations 😭

valid jetty
#

this is not an include guard its called something else

fleet cedar
#

Probably called a tarball or something

#

Since that's what that is

winged mantle
valid jetty
#

you dont is how

#

if you want a single file library you do the thing i showed

winged mantle
#

if i have a.c include a file defining func1 and b.c including a file defining func1 too that would not work

valid jetty
#

nope it wouldnt

winged mantle
#

even with a traditional include guard

#

i am confused... did you realise you were wrong

#

impossible

valid jetty
#

yes lol i was wrong from the start i wasnt sure what you meant

valid jetty
winged mantle
#

that doesn't really help lol

#

i don't have any reason to combine the file into one

valid jetty
#

well then what did you mean earlier by single header library 😭

winged mantle
#

why doesn't rust have headers that would be cool

valid jetty
winged mantle
#

i swear i've seen header only libraries where you don't need that

#

but for c++

valid jetty
#

well yeah its completely different for c++

winged mantle
#

i have done more C++ than c

lavish frigate
# winged mantle like https://github.com/nlohmann/json

so many words.. so many just to say quit and use serde_json

use serde_json::json;

let data = json!({
  "name": "John Doe",
  "age": 43,
  "phones": [
      "+44 1234567",
      "+44 2345678"
  ]
});

println!("first phone number: {}", john["phones"][0]);
valid jetty
#

wtf since when can you index json in rust like that

#

is it using dyn

lavish frigate
#

Rust is just so cool

winged mantle
lavish frigate
#

Idk how it works exactly I just know that serde and by extension serde_json is peak

winged mantle
#

just use js

#

{
name: "John Doe",
age: 43
}

#

uses json5 syntax instead of json

lavish frigate
#

what is js

winged mantle
#

why do i have brain rot

#

i read this and think of this gif

lavish frigate
#

serde reference

valid jetty
#

@deep mulch finally it works

#

you can do this

use std/prelude;

fn main() {
    $dbg([1, 2, 3].map(fn(x) "{}".format(x)));
}
#

and it properly infers what T is, then whatx is, then what U is

winged mantle
winged mantle
#

this feels a bit dirty lol

deep mulch
#

delete

valid jetty
#

nvm it still doesnt work properly

deep mulch
#

love

#

@valid jetty

valid jetty
#

if more generics are found after the function, the function wont be re-monomorphized with what we now know

fn Array::map_with<T, U, V>(T[] self, fn(T, V, u64, T[]) -> U mapping, V arg) -> U[] {
    let new_self = Array::with_capacity<U>(self.len());

    for u64 i = 0; i < self.len(); i += 1 {
        new_self.push(mapping(self[i], arg, i, self));
    }

    return new_self;
}
#

V is deduced after the mapping is compiled

deep mulch
#

implicit self implicit self implicit

valid jetty
#

nop

deep mulch
#

yop

valid jetty
#

ok i know how to do this

#

i need to generate into a stub module

#

then that means the third compilation is actually necessary

#

unfortunate

winged mantle
#

how should i handle the size of a string growing larger than the largest 64-bit integer

#

imagine giving a server a quintillion bytes to abuse use after free

#

or something like that

deep mulch
#

Elle for quantum computing

#

@valid jetty add qubits to elle

winged mantle
#

add built in ui

winged mantle
#

but it should catch it in non debug

valid jetty
#

well youre working in C

#

you cant exactly return a Result

#

@deep mulch i was right it worked

winged mantle
valid jetty
#

they will only do that if you ran out of memory

#

but you can return a bool from the function

#

false if it fails

#

so you can do if (!json_read(...)) return 1

#

or whatever

winged mantle
#

i don't think i have a single void function

#

nvm

#

i have one

#

wait can you not just do return { .name = "joe" } in c

#

this is c99 tbf

valid jetty
#

im pretty sure you can

#

oh no you cant

#

this is the best you can do

#include <stdio.h>

typedef struct {
    int x;
} Foo;

Foo Foo_new() {
    return (Foo) {
        .x = 39
    };
}

int main() {
    Foo foo = Foo_new();
    printf("%d\n", foo.x);
}
#

@hoary sluice look at this js code

[1, 2, 3].map(fn(x) x * 2)
``` or ```rs
[1, 2, 3].map(fn(x, i) {
    $dbg(i);
    return x * x;
});
``` or ```rs
[1, 2, 3].map(fn(x, i, arr) {
    $dbg(i, arr);
    return x - 1;
});
ionic lake
#

make elle ui framework, elle compiler collection, elle os, elle browser, elle kernel, elle fan, elle sweatshirts, elle banana

valid jetty
#

@deep mulch

deep mulch
valid jetty
#

strong typing in Result::resolve

#

the resolve function is supposed to let you ""match"" on a result

#

but the first branch is returning an i32

#

the second branch is returning a string

#

so its throwing an error

deep mulch
#

sounds cursed

valid jetty
#

in rust its like

fn main() {
    let x = Ok(39);

    let y = match x {
        Ok(val) => val,
        Err(_) => "a"
    };
}
``` and this will throw an error
deep mulch
#

what is val => val

valid jetty
#

oops

valid jetty
#

this makes me so happy

deep mulch
#

This

#

Inferred return type string

calm terrace
#

typescript is just pedantic javascript

valid jetty
#

@hoary sluice @deep mulch @placid cape iterators

use std/prelude;

struct Iterator<T, Env> {
    Box<Env> env,
    fn(Env *) -> Option<T> cb
}

fn Iterator::next<T, Env>(Iterator<T, Env> self) {
    cb := self.cb;
    return cb(self.env.to_ptr());
}

fn Array::iter<T>(T[] self) -> Iterator<T, (i32, T[])> {
    return Iterator {
        env = Box::new($(0, self)),
        cb = fn(env) {
            i, self := env;

            if i < self.len() {
                env.x += 1;
                return Option::Some(self[i]);
            } else {
                return Option::None<T>();
            }
        }
    };
}

fn main() {
    x := [1, 2, 3].iter();

    while _, val := x.next() {
        $dbg(val);
    }
}
valid jetty
#

what a difference blobcatcozystars

spark tiger
#

wsl is open source now!

valid jetty
#

why is it staring into my soul

fleet cedar
#

You have one?

valid jetty
#

i hope so

fleet cedar
valid jetty
#

lazy ranges and stuff

winged mantle
valid jetty
#

oh my god it still doesnt fully work

formal belfry
#

thoughts on delegation stuff @solemn ravine @woven mesa

#

this feels so blegh but i dont know how else to do it, especially in a delegate pattern

spark tiger
#

notification summary is just anything atp 😭

spark tiger
woven mesa
#

#define DISCORDPP_IMPLEMENTATION

#

@formal belfry

valid jetty
woven mesa
#

@formal belfry first roadblock

valid jetty
#

i offload the monomorphization of function defs that contain generics to after everything else is monomorphized

#

that way everything is inferred for functions right at the end

formal belfry
#

lol

woven mesa
#

is this what you were stuck with

#

i forgor

formal belfry
#

no but similar

woven mesa
#

o

deep mulch
#

you don't sleep so you don't have

valid jetty
#

@deep mulch

deep mulch
#

@valid jetty

#

@valid jetty I'm eepy

#

I EEPED

#

@valid jetty

valid jetty
#

i slept too

#

3am to 7am

woven mesa
#

@formal belfry i got it compiling and working and authenticating

valid jetty
#

@deep mulch is this comment small enough

// offload lambda monomorphization until after everything else is monomorphized
// because the lambda's return type may depend on generics which arent known yet
//
// consider:
//
// fn foo<T, U>(fn(T) -> U x, T b) {
//     $dbg(x(b));
// }
//
// foo(fn(x) "{}".format(x), 5);
//
// in this, the return type requires that we know x's type, but this is deduced after
// the lambda definition (T = i32 is deduced from `T b`[5])
//
// if we try to generate the body without knowing T, we will call `T::__fmt__`, which
// we can't guarantee will have a definition, so the compiler will throw an error
//
// instead, we don't do this right away, and just defer it.
//
// after all other generics are deduced, we now know T, so we can now generate the body
// as this is monomorphized with T = i32, and we know that `i32::__fmt__` exists so
// we can confidently generate that U = string, monomorphizing everything as a result.
if ty.is_function() {
    deferred_generics.push((i, param_ty.clone(), parameter.1));
}
deep mulch
#

I overslept by 2 hours

valid jetty
#

WHERE IS MY SYNTAX HIGHLIGHTING

valid jetty
#

this also means you can use the return type to deduce the inner type of the lambda

woven mesa
valid jetty
deep mulch
valid jetty
#

this is starting to become really really complicated

#

scary

shrewd canopy
#

Tho i use oauth2 api directly so no need for native interop

valid jetty
boreal minnow
#

can I ask about JavaScript here?

#

or do I get yeeted out

valid jetty
#

ofc !

boreal minnow
#

wait yeeted out?

#

no way

valid jetty
#

no ofc you can ask lol

lucid trail
boreal minnow
#

but seriously does anyone know how to get token using the webpack things?

valid jetty
boreal minnow
#

my code doesn't work anymore 😢

#

and I'm probably dead just by asking it lol

lucid trail
valid jetty
boreal minnow
#

I am not trying to commit any crime I swear I just need a more simpler way to get the token

#

😭

valid jetty
#

nvm i actually

#

just figured it out on my own

#

its just Vencord.Webpack.findByProps('getToken').getToken() lol

#

who couldve guessed

boreal minnow
#

huh interesting thank you so much

#

pls don't ban me

#

😭

boreal minnow
#

I think the last time I asked about anything related to tokens I got banned

valid jetty
deep mulch
#

if Rosie says complicated then it's impossible for me

valid jetty
#

true

lucid trail
deep mulch
#

@valid jetty is genius

valid jetty
#

you just cant call fields in structs inline

#

because it thinks its a struct method

deep mulch
#

Fixxxx

#

@valid jetty add array joining like arr1 + arr2

valid jetty
#

when you do self.next() it doesnt know whether you mean (self.next)() or Self::next(self)

valid jetty
deep mulch
#

extend isn't a good choice I think

valid jetty
#

its what rust uses

deep mulch
#

Elle is rust

valid jetty
#

in 4 years im gonna write a borrow checker

lucid trail
valid jetty
#

single threaded mark&sweep stop the world

#

ill need to rewrite the gc eventually because its slightly wrong right now

deep mulch
#

@valid jetty @valid jetty @valid jetty @valid jetty @valid jetty

valid jetty
#

@deep mulch have you made any progress

valid jetty
#

do

deep mulch
#

guhhh motivation

#

@valid jetty

#

@valid jetty you sap my motivation away to work on Elle

#

you will return it

#

Rosie feeds on my motivation and energy

#

that's why I'm so eepy all the time

fleet cedar
#

Like a vampire?

deep mulch
#

yes

valid jetty
#

yeah

#

i am a vampire

deep mulch
hoary sluice
#

@valid jetty

#

wrong chat

valid jetty
#

yayyy

#

good job

hoary sluice
#

what next

formal belfry
#

@woven mesa does AXSwift's observing just not work

#

do you know

spark tiger
#

don’t yell 😭

valid jetty
woven mesa
#

oi

formal belfry
#

this doesnt work at all and idk why

#

nothing is ever printed

woven mesa
#

oh actually idk if i did or not

formal belfry
#

pretty sure you did

woven mesa
#

guhh

#

@formal belfry did u read axswift docs

formal belfry
#

yeah

woven mesa
formal belfry
#

if you mean by reading the code of axswift yeah cos theres no docs xd

woven mesa
#

i accidentally airdropped my dad axswift

formal belfry
#

truee

woven mesa
#

i interrupted lesson

#

guh

formal belfry
#

does discord have an api for checking if an rpc asset exists

woven mesa
shrewd canopy
median root
#

OH MY GOD ive just found out the entire reason my code felt jank was because more than half of the backend had a synchronous macro on the function.

#

im never using sync functions again

#

everything async or threaded from now on

#

its so smooth now!!!!

winged mantle
#

upcoming project readme

Based on football concepts, so it should be easy to understand even if you're really stupid.

worldly sigil
#

which one of yall wants to buy the 122tb ssd for $16,345

frosty obsidian
deep mulch
#

@frosty obsidian doesnt know what football is

#

@frosty obsidian has never played sports

frosty obsidian
#

that's mostly true

deep mulch
#

@frosty obsidian doesnt know how to run

valid jetty
#

@hoary sluice i just had the most genius idea to impose compile-time restrictions on reversing an iterator which may not have a next_back

#

instead of returning a Result<T, E>

#

i can have a phantom generic on the iterator struct

#
namespace SingleEnded;
namespace DoubleEnded;

struct Iterator<T, Env, Kind> {
    Box<Env> env,
    fn(Env *) -> Option<T> next,
    fn(Env *) -> Option<T> next_back
}
#

then i can make rev only allow DoubleEnded iterators

#
fn Iterator::rev<T, Env>(Iterator<T, Env, DoubleEnded> self) -> Iterator<T, Env, DoubleEnded> {
    return Iterator {
        env = self.env,
        next = self.next_back,
        next_back = self.next
    };
}
#

which throws a compile time error if the iterator is not double ended

#

and this too

#

ofc array iterators should be reversible

#

but as an idea

#

wtf is this function signature 🥀 💔

valid jetty
#

yeah ok this is getting out of hand 😭

#

works tho?? literally slay

#

clean code?? pfft

fn Iterator::map<T, U, Env, Kind>(
    Iterator<T, Env, Kind> self,
    fn(T) -> U cb
) -> Iterator<U, (Iterator<T, Env, Kind>, fn(T) -> U), Kind> {
    return Iterator {
        env = Box::new($(self, cb)),
        next = fn(env) {
            self, cb := env;
            return self.next().map(cb);
        },
        next_back = self.next_back ? fn(env) {
            self, cb := env;
            return self.next_back().map(cb);
        } : nil
    };
}
deep mulch
#

@valid jetty hiii

valid jetty
#

hii

valid jetty
#

i thought i was onto something with this function

#

(this is literally just a redefinition of Option::map)

valid jetty
#

@hoary sluice ever wanted type hell?

#

beautiful

#

LMAOOOOOOO

#

WHAT THE FUCK IS THIS

#

im crying

#
%tmp.2267 =:Tuple.0.Iterator.0.11.Tuple.0.Iterator.0.11.Tuple.0.Iterator.0.11.Tuple.0.Tuple.0.11.7.1.2.Array.0.11.1.1.DoubleEnded.1.98.0.11.11.1.1.DoubleEnded.1.98.0.11.11.1.1.DoubleEnded.1.98.0.11.11.1.1 call $Tuple.__tuple__.0.Iterator.0.11.Tuple.0.Iterator.0.11.Tuple.0.Iterator.0.11.Tuple.0.Tuple.0.11.7.1.2.Array.0.11.1.1.DoubleEnded.1.98.0.11.11.1.1.DoubleEnded.1.98.0.11.11.1.1.DoubleEnded.1.98.0.11.11.1.1(:Tuple.0.Iterator.0.11.Tuple.0.Iterator.0.11.Tuple.0.Iterator.0.11.Tuple.0.Tuple.0.11.7.1.2.Array.0.11.1.1.DoubleEnded.1.98.0.11.11.1.1.DoubleEnded.1.98.0.11.11.1.1.DoubleEnded.1.98.0.11.11.1.1 %env.2264)```
#

this is a single assignment

valid jetty
#

lol

#

good luck explicitly declaring your variable with that type

deep mulch
#

@valid jetty SLEEP

fleet cedar
valid jetty
hoary sluice
fleet cedar
#

No you can't

hoary sluice
fleet cedar
#

How would you reverse an iterator that only has one end

hoary sluice
#

create a double ended iter, pop from the single ended and push them to the front of the double ended

fleet cedar
#

So you mean collect into a vec and iterate that?

hoary sluice
#

does rosie have infinite iterators

hoary sluice
fleet cedar
#

In other words, not reversing the iterator

hoary sluice
#

how is that not reversing it

fleet cedar
#

You are traversing the iterator and then reversing the result

hoary sluice
#

reversing an iterator means the front turns into the back

fleet cedar
#

You are throwing away the laziness of the iterator

#

And potentially wasting shitloads of memory

hoary sluice
#

better than crashing

fleet cedar
#

Why the fuck would it crash

#

A compile error is not a crash

hoary sluice
#

ok its a compile time error you can just make it double ended

#

the error message should be more descriptive thought maybe

#

you clearly can reverse a single ended iterator, its just slow, so it should tell you that and not "cannot cast to doubleended"

fleet cedar
#

You can not

#

You can reverse its results

#

Which is a very different thing

#

Sure, adding a "note: you can collect to a vec and reverse that" sounds harmless enough

hoary sluice
#

whats the overhead of a double ended iterator

fleet cedar
#

Zero for things that support it, infinite for things that don't

hoary sluice
#

what if you have a single ended where you insert a billion items, pop a billion items, add 3 items and reverse it

#

would that be faster with double ended

fleet cedar
#

You seem to have a very strange idea of what an iterator is

#

You do not insert things in an iterator

#

An iterator is a traversal

#

Some traversals (such as over vec) can be done in both directions, others (such as over lines of stdin) can not

hoary sluice
#

make an iterator with a billion items, traverse it 999999997 times, then reverse it

hoary sluice
valid jetty
#

the iterator may be infinite

valid jetty
#

there may never be a case when the iterator ends

hoary sluice
fleet cedar
#

What language requires iterators to be finite

valid jetty
fleet cedar
#

An iterator is just a function that gives the next value

valid jetty
#

yeah

ocean oyster
ocean oyster
valid jetty
#

what

#

someone setup their selfbot wrong !!!

#

love

fleet cedar
#

yeah 1374720297802137732

#

Huh, apparently that's not how you use it

valid jetty
#

iterators couldve existed in elle before but they would’ve been awkward to use because you couldn’t specify the prototype of function parameters (which means you couldn’t infer like, anything, among other issues of the fact that you need to cast void to your real return type which means void had a size of 8 bytes)

#

now that i wrote all these qol things (function signatures in the type system, much higher quality generic inference/deduction, lambda arg type inference) iterators become so silly and useful

hoary sluice
#

im just used to iterators being something that is made from collections

#

infinite ones in my lingo (kotlin lingo) are sequences

fleet cedar
#

They commonly are, yes

hoary sluice
#

so i assumed that iterators can be finite

fleet cedar
#

They sure can

hoary sluice
#

i mean

#

can be finite only

#

like some languages can have no infinite iterators

fleet cedar
#

What languages

#

Do they exist?

hoary sluice
#

well kotlin has sequences, which generate new values on the fly using a function that is passed the index, and it also has iterators, im not sure if sequences are a subclass of iterators or if iterators are finite

valid jetty
#

any language can have finite or infinite iterators if it can take in functions into other functions and can mutate a struct lol

hoary sluice
#

iterators are just an interface with hasNext and next so theyre infinite

hoary sluice
valid jetty
#

so then what were you saying earlier about whether elle iterators can be infinite

#

an iterator by definition can be infinite because it just yields the next value which may never have an end

hoary sluice
#

but as a language construct or stdlib impl im sure theres at least one language that doesnt have infinite iterators and has a good reason for it

valid jetty
#

true