[ / / / / / / / / / / / / / ] [ dir / alita / arepa / choroy / dempart / f / femdom / vichan / zoo ][Options][ watchlist ]

/tech/ - Technology

You can now write text to your AI-generated image at https://aiproto.com It is currently free to use for Proto members.
Email
Comment *
Verification *
File
Select/drop/paste files here
Password (Randomized for file and post deletion; you may also set your own.)
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Expand all images

File (hide): 49e97619572b23f⋯.jpg (144.56 KB, 1024x768, 4:3, 3028014384_c6589002f7_b.jpg) (h) (u)

[–]

 No.1066915>>1066917 >>1067184 >>1067335 [Watch Thread][Show All Posts]

>Lispers: prefix notation is superior

<Forthers: postfix notation is superior

I say the omnifix notation is superior. The omnifix function call syntax allows the arguments to be placed for OR after the function. It is an extension of the UFCS or method call syntax that is present in Nim, D, and possibly other languages.

What is UFCS? In C-style languages where the dot operator is typically used as the property access operator for objects, structs, or any other dictionary-like data structure, the dot operator is given the additional role of transforming syntax as follows:


//The following are equivalent
f(a);
a.f();
a.f; // empty parens optionally dropped


//The following are equivalent
f(a, b, c);
a.f(b, c);

Thus, it allows a function written outside a class (or if the language doesn't have classes) to be used as if it were a "method" of an object. Here's what it looks like in imaginary curly-brace language:


// declare a type O to be an object that has a property p of type P
typedef O =
object {
p: P
};


// when you make this declaration, it's like there is implicity declared a getter:
func __get_O_p(o: O): P;

// and a setter:
func __set_O_p(o: O, p: P): void;

//so...
o.p;
//is equivalent to
__get_O_p(o);

//and...
o.p = p2;
//is equivalent to
__set_O_p(O, p2);

This syntax is present in several languages. But what if it were extended to handle more than one argument, so that the following is true:


f(a, b, c, d)
== a.f(b, c, d)
== b.a.f(c, d)
== c.b.a.f(d)
== d.c.b.a.f()
== d.c.b.a.f; // empty parens optionally dropped

Now you can have prefix AND postfix, together in one unified syntax. And you don't need class keywords.

It also works with named arguments.


func f(a: int, b: int, c: int): int {
(a + b) * c;
}

// Prefixedly:
f(1, 2, 3); // == 9;
f(c = 3, a = 1, b = 2); // == 9;

// Postfixedly:
3.2.1.f; // == 9;

// Omnifixedly
3.1.f(b = 2); // == 9;
3.f(b = 2, a = 1); // == 9;

 No.1066917>>1066925

>>1066915 (OP)

That's pretty interesting. Omnifix is a step above infix. Omnifix allows infix, prefix, and postfix. One declares which one they want.


 No.1066925

>>1066917

>Omnifix allows infix, prefix, and postfix. One declares which one they want.

Ok, but isn't having three different notation types going to slow down compilation?


 No.1066935

> Our syntax is shit, so let's add ten more alternative ways of writing things

Stop. Please, for the love of God, just stop this madness. Prefix, postfix, I don't care, just pick one and be done with it.


 No.1066940

What about suffix

(arguments...)method<-object


 No.1066943>>1067172

Syntax is just a way to describe what you want the hardware to do.

At the end of the day it's machine code running and executing instructions, so as long as there's no ambiguity with what is written and the meaning of it, who cares?

Also

>f(a, b, c, d) == d.c.b.a.f

What happens if you have an object that has a method that returns another object? Will you just break it down on multiple lines?

Then it's the same as writing "I have this root to use with these leaves" and "I have these leaves and want to use this root"

>it allows a function written outside a class (or if the language doesn't have classes) to be used as if it were a "method" of an object

Do you mean a global function? Why do you need to have it as a "method" of an object?

Sound like someone want to be special by reinventing the wheel and forgot that coding is just a mean to an end.


 No.1067172

>>1066943

>Sound like someone want to be special by reinventing the wheel and forgot that coding is just a mean to an end.

This. The ones who don't think so write Java or teach others coding.


 No.1067184

>>1066915 (OP)

>make your code less readable by almost certainly having nu-programmers switch style 5 times a line

>slow down compilation since you have to check every line for every notation

>make your compiler bigger

A notation isn't hard to learn, you can get it down in one afternoon. Not worth the hassle.


 No.1067335

File (hide): a07cf13582bf22c⋯.jpg (26.59 KB, 620x469, 620:469, rppwhkzmc4a01[1].jpg) (h) (u)

>>1066915 (OP)

<If I add ALL the possible syntaxes and ways to do things it will certainly make a better language.

No. Also, the syntax of lisp is purposely bare-bone to go in line with its meta-programing /code-is-data philosophy. Any syntactic possibility should have a good reason for existing, and recommended use-cases besides 'muh choice' .




[Return][Go to top][Catalog][Screencap][Nerve Center][Cancer][Update] ( Scroll to new posts) ( Auto) 5
8 replies | 1 images | Page ???
[Post a Reply]
[ / / / / / / / / / / / / / ] [ dir / alita / arepa / choroy / dempart / f / femdom / vichan / zoo ][ watchlist ]