Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Does C actually need ; {}[]?

Name: Anonymous 2017-02-28 4:18

Does it?

Name: Anonymous 2017-02-28 4:38

saw this on reddit: http://www.theodo.fr/blog/2017/02/i-challenge-you-to-debug-those-7-lines-of-code-under-9-minutes/

def foo(a, methods=[]): # methods defaults to [] if not specified
for i in range(3):
# Append an anonymous function, which returns `x + i`
# when given `x`
methods.append(lambda x: x + i)

sum_methods = 0
# For each function `method` of in `methods`, sum `method(a)`
for method in methods:
sum_methods += method(a)
return sum_methods


You expect your function to output the following:
foo(0) = (0 + 0) + (0 + 1) + (0 + 2) = 3
foo(1) = (1 + 0) + (1 + 1) + (1 + 2) = 6
foo(2) = (2 + 0) + (2 + 1) + (2 + 2) = 9
foo(2, [lambda x: x]) = ((2)) + ((2 + 0) + (2 + 1) + (2 + 2)) = 11

Simple, right? Let’s try it in our terminal.
foo(0)
6
foo(1)
18
foo(2)
36
foo(2, [lambda x: x])
14

Well, there seems to be a minor error. But wait, could we have missed something? Let’s check again.
foo(0)
24
foo(1)
45
foo(2)
72

WHAT.

THE.

how much abuse do you have to take before you accept that he doesn't love you?

how much FORCED INDENTATION OF CODE is it going to take before thread over

Name: Anonymous 2017-02-28 4:39

"it's a common pitfall"

hahahaha. it's bad language design.

Name: Anonymous 2017-02-28 4:40

"the lack of closure on for-loops issue"

jesus christ....

guido. that book we sent you? open it.

Name: sage 2017-02-28 4:44

; {}[]
That's not even syntactically correct C. Are you trying to write a C++ lambda?

Name: Anonymous 2017-02-28 7:41

>>2
this has nothing to do with the lack of braces in python, this is because the default value is only evaluated on the first call and referenced from then on so mutating it can silently break your functions. it's one of the worst design choices in the language but it's a separate issue from FIOC/significant whitespace

Name: Anonymous 2017-02-28 16:35

>>6
I know. Your thread is shit so i made it about python instead.

Remember when the egotistical demagogue decided to split python into python2/python3. Forcing: Poeple to to rewrite their scripts, distros to duplicate work packaging both versions of python, everybody to have 2x as much disk space and upgrade time used up by pip/pip3 packages!

Well this boy has decided to make a new language that runs both python2 and python3 code https://www.naftaliharris.com/blog/nonlocal/

How much crap are people going to take before they say no?

Name: Steve 2017-02-28 16:39

forced indentation of code they tryna control me

Name: Anonymous 2017-03-01 20:19

>>2
This thread is not about FIOC. It's about if C actually needs any of these characters.

{} for example could be changed with () (also notice the lack of ;)
while (penis) (
printf("Dicks")
x = ducks + penis--
y = ducks++
)


[] could also be replaced with ()
int x(10)
x(0) = 5


The only case I can think of that might cause a problem is dumb shit like
x = 1
+ 5 /* x becomes 6 */

or
x = 1
- 5 /* x becomes -4 */


When in actual C you would write
x = 1; /* x becomes 1 */
+ 5; /* ignored */

and
x = 1; /* x becomes 1 */
- 5; /* ignored */

Name: Anonymous 2017-03-01 20:27

>>2 just like scheme lol
> (define x 0)
> (define (f i) (+ x i))
> (set! x 5)
> (display (f 0))
5

Name: Anonymous 2017-03-02 2:43

This thread is now about DEEP DICKING

Name: Anonymous 2017-03-02 8:13

>>11
How deep?

Name: Anonymous 2017-03-02 12:57

>>10
JavaScript is another mainstream Scheme dialect.

Name: Anonymous 2017-03-02 13:08

Name: Steve 2017-03-02 14:08

>>9
Parentheses for subscripting? What the fuck is this, some shitty Matlab clone? Matlab is shitty enough as it is.

Name: Anonymous 2017-03-02 14:18

>>9
That's the worst of both worlds. Now you have delimiters and the language is whitespace-sensitive.

Name: Anonymous 2017-03-02 16:59

>>16
No, it isn't. You still can do prinf("thing")printf("thing")
There is nothing whitespace-sensitive about it.

Name: Anonymous 2017-03-02 21:04

I think [] and {} are better for clarity, though I agree with your point about semicolons. For example, Lua completely ignores newlines, and semicolons are only needed to disambiguate in some very rare cases.
http://www.lua.org/manual/5.2/manual.html#3.3

Name: Anonymous 2017-03-02 21:42

>>18
In that case this should mean that it should be able to have a C implementation inside a lisp macro.

Name: Steve 2017-03-02 22:14

lol u tk him 2da bar|?

Name: Anonymous 2017-03-03 9:05

>>20
Mike "Alternative Current" Pence: Laughter is the best medicine, but electricity second best.

Name: Steve 2017-03-03 14:27

>>21
I dubs your fucking pardon????

Name: Anonymous 2017-04-19 18:17

bumpy titties

Name: Anonymous 2017-04-19 18:50

>>9
This is just horrible.

Name: Anonymous 2017-04-19 19:28

>>24
How can C encoded as a valid S-expression be horrible?

Name: Anonymous 2017-04-19 22:30

What you can do is make a separate language which has the syntax and semantics you want. There are a lot of readable languages that do not look like Lisp or C.

Name: Anonymous 2017-04-19 22:34

int x(10)
x(0) = 5


I don't think this is a good idea, as you've introduced a syntactic ambiguity between function calls and array access.

For example:

int result = x(0);

Is the right-hand side calling a function 'x' with argument 0, or retrieving the 0th element of array 'x'? This might not impact the compiler much, but it's awful for readability.

The programmer should not have to keep the whole symbol table in her head just to understand how the syntax is being parsed. Down that road lies C++.

Name: Anonymous 2017-04-20 5:38

>>27
array(index) is the indexing syntax in Fortran, PL/I, Ada, Cobol, and Basic and it's also used for function calls. Algol 68 allows both [] and (). Snobol allows both [] and <>.

There's also a view that arrays are functions.

Name: Anonymous 2017-04-20 10:11

>>28
They may have had that, but it doesn't change the fact it's a bad design choice.

Name: Anonymous 2017-04-20 11:21

>>29
Variables and functions are both just named memory locations. The only thing that differs is their contents.

Name: Anonymous 2017-04-20 13:54

>>30
I don't want to look at someone's code and wonder whether he was accessing an index or calling a function, sry

Name: Anonymous 2017-04-20 14:48

>>31
Even if it's a same thing?

Name: Anonymous 2017-04-20 18:08

http://dl.acm.org/citation.cfm?doid=2543488.2534973
We followed up with two studies on the accuracy rates of novices using a total of six programming languages: Ruby, Java, Perl, Python, Randomo, and Quorum. Randomo was designed by randomly choosing some keywords from the ASCII table (a metaphorical placebo). To our surprise, we found that languages using a more traditional C-style syntax (both Perl and Java) did not afford accuracy rates significantly higher than a language with randomly generated keywords, but that languages which deviate (Quorum, Python, and Ruby) did.

https://www.gnu.org/fun/jokes/unix-hoax.html
"In 1969, AT&&T had just terminated their work with the
GE/Honeywell/AT&&T Multics project. Brian and I had just started
working with an early release of Pascal from Professor Nichlaus Wirth's ETH
labs in Switzerland and we were impressed with its elegant simplicity and
power. Dennis had just finished reading 'Bored of the Rings', a
hilarious National Lampoon parody of the great Tolkien 'Lord of the
Rings' trilogy. As a lark, we decided to do parodies of the Multics
environment and Pascal. Dennis and I were responsible for the operating
environment. We looked at Multics and designed the new system to be as
complex and cryptic as possible to maximize casual users' frustration
levels, calling it Unix as a parody of Multics, as well as other more
risque allusions. Then Dennis and Brian worked on a truly warped
version of Pascal, called 'A'. When we found others were actually
trying to create real programs with A, we quickly added additional
cryptic features and evolved into B, BCPL and finally C. We stopped
when we got a clean compile on the following syntax:
for(;P("\n"),R--;P("|"))for(e=C;e--;P("_"+(*u++/8)%2))P("| "+(*u/4)%2);

Name: Anonymous 2017-04-26 1:01

>>33
what's your point dude

Don't change these.
Name: Email:
Entire Thread Thread List