Post 9rlIOenodbnhbSCBqy by alva@beach.city
 (DIR) More posts by alva@beach.city
 (DIR) Post #9rl01K8zTtHThFpACu by isi@princess.cat
       2020-02-06T09:45:30.767091Z
       
       0 likes, 0 repeats
       
       !!I am searching for a programming language!!My father has implemented a script language for his special physics stuff where there are different variable declaration optionsyou could just normally use a declaration as its commonly known where you have an a = blub and b = a and even if you change a to a = blob afterwards, b would still be blubbut you could also use another type of declaration (I can't remember the symbol...) where b would be "linked" to a and automatically update itself when you change a somewhere in the programso you could for example say:a = "name"b = "hello" + a (it uses a different symbol than "=" but I still don't remember what)a = "isi"println(b)> hello isiis there somewhere a much better known language out there that can do stuff like that as easily as there? I reaaally don't want to use a niche language that's used for only some few projects at one institute :blobcathappy:
       
 (DIR) Post #9rl0pj7ct60fdyDhRI by ivesen@miniwa.moe
       2020-02-06T09:54:33.817455Z
       
       1 likes, 0 repeats
       
       @isi you can kinda do that in C tbh, what you're looking for is a language that lets you use reference types freely (which is most languages), and with string interpolation.lemme check if I can do it in python
       
 (DIR) Post #9rl1RouVoYykbIFZvU by ivesen@miniwa.moe
       2020-02-06T10:01:29.530515Z
       
       1 likes, 0 repeats
       
       @isi I feel like I'm gonna end up suggesting haskell to make it work exactly the way you explained @…@
       
 (DIR) Post #9rl1UWzct6tNtnw2Do by isi@princess.cat
       2020-02-06T10:01:59.811242Z
       
       1 likes, 0 repeats
       
       @ivesen can you give me an easy example for both c and python? :blobcat:I had c in university just until a week ago but it was so stupid... we were forced to implement stuff like DATA STRUCTURES (stack, dynamic array, ...) where you were wishing for a fucking class construct and didn't do any REAL c stuff like headers or cool elegant pointer arithmetik and stuff :meowumm:
       
 (DIR) Post #9rl1XISbNOfvhBo5cu by isi@princess.cat
       2020-02-06T10:02:30.645292Z
       
       0 likes, 0 repeats
       
       @ivesen that would be okay too, then I would have a motivation to finally look into it :blobcathappy:
       
 (DIR) Post #9rl1YswnCj3T9CgaI4 by Feuerfuchs@fedi.vulpes.one
       2020-02-06T10:01:12.526941Z
       
       1 likes, 0 repeats
       
       @isi Sounds to me like that other type of declaration lets you define a very simple function which looks like a variable. So in, let's say JS, you should get the same kind of behavior with very similar code:a = "name";b = () => "hello " + a;a = "isi";console.log(b());You should get similar results with other languages. In C++ it would bestd::string a = "name";auto b = [&] { return "hello " + a; };a = "isi";std::cout << b();
       
 (DIR) Post #9rl1cZBYcWL511LaxU by isi@princess.cat
       2020-02-06T10:03:27.687950Z
       
       0 likes, 0 repeats
       
       @Feuerfuchs but I want it to look like a variableeee :((((((
       
 (DIR) Post #9rl1qRLYYrKml4diwS by Feuerfuchs@fedi.vulpes.one
       2020-02-06T10:04:22.803674Z
       
       1 likes, 0 repeats
       
       @isi :blobfoxthink:
       
 (DIR) Post #9rlB4dNHXPvthgI1w0 by ivesen@miniwa.moe
       2020-02-06T11:49:20.884149Z
       
       1 likes, 0 repeats
       
       @isi I fucked about with it for a bit (and ate lunch lul)I couldn't make it work like I wanted in python :blobcatsad: and making it work nicely with strings in C is kinda a pain (feuerfoxxo already posted the c++ equivalent, and the C version isn't going to be any nicer, I said "kinda" in the please don't version of kinda :v )and I don't actually know haskell, so while it should be fairly easy, you have to do some magic to make it actually work :blabcat: sowwy ;_;
       
 (DIR) Post #9rlB8j2UQ2DuQkW0n2 by isi@princess.cat
       2020-02-06T11:50:07.216690Z
       
       0 likes, 0 repeats
       
       @ivesen thank you for your effort :blobcatheart: :meowsignthx:
       
 (DIR) Post #9rlIGLRKkAoTEaiSoK by alva@beach.city
       2020-02-06T13:06:43Z
       
       1 likes, 0 repeats
       
       @isi I think what you're talking about is "value semantics" in the first example, and "reference semantics" in the second. So any language that has values and references should be able to do that. Example in C:// Valueint a = 42;int b = a;a = 43;assert(b == 42); // unchanged// Reference (pointer)int a = 42;int *b = &a;a = 43;assert(*b == 43); // merely refers to `a`(Untested, but I think it's correct)
       
 (DIR) Post #9rlIOenodbnhbSCBqy by alva@beach.city
       2020-02-06T13:11:10Z
       
       1 likes, 0 repeats
       
       @isi Rust would be a more modern alternative that can do this in a safer way
       
 (DIR) Post #9rlIoYITRozGxJspyC by felix@radical.town
       2020-02-06T13:14:54Z
       
       1 likes, 0 repeats
       
       @alva @isi exactly this. Generally the languages that support this are system programming languages, like C, C++ or Rust. But there are also ways to get this behaviour in other languages.