News for hackers. Stuff that matters.
Re:The cost of forsaking C by barrkel on Wednesday October 05, 2016 @05:17AM (#12642526)
I'm guessing you mean `array[10] of pointer to int`.

This is pretty close to Pascal syntax already: `array[0..9] of ^Integer`, where ^ is pronounced 'pointer to'.

Pascal is a language that is genuinely easy to parse; it's designed to be LL(1). C is not; in particular, typedefs effectively introduce keywords, and the easiest way to parse C is to inform the tokenizer about typedefs as they're found so the parser can disambiguate things like `a (b);`; this looks simultaneously like declaring a variable and calling a function, depending on the type of 'a'.

Re:The cost of forsaking C by Roboprog on Wednesday October 05, 2016 @11:44AM (#12644822)
Maybe I'm missing something, but I think Pascal "TYPE" blocks and C "typedef" statements do pretty much the same thing.

(they don't look the same, but you can use either to define record/structure types or enums, for example)

Re:The cost of forsaking C by barrkel on Wednesday October 05, 2016 @03:00PM (#12646724)
The distinction is in the syntax.

    int main()
    {
       foo(bar);
       foo * bar;
    }
If foo is a typedef, these are variable declarations, otherwise the first is a function call and the second multiplication (syntactically). These are different kinds of things that would normally be up to the parser to figure out (rather than semantic analysis later). These are well-known ambiguities relating to typedefs in C (well-known to compiler authors, at any rate).

The situation doesn't come up in Pascal because variables go in the var block (starting with the 'var' keyword) and functions and procedures both start with keywords ('function' and 'procedure').

Re:The cost of forsaking C by Roboprog on Wednesday October 05, 2016 @05:04PM (#12647869)
OK, thanks. I was focusing on the "definition" part, rather than the "usage" part of the types.

It never occurred to me to put variables names inside parens in a declaration when I did C, though. But OF COURSE it's legal obfuscation.

As stated elsewhere, I don't know why C had to screw up Algol's syntax so badly. I guess K&R liked curly braces much more than BEGIN/END, and why stop there, once you get going. Maybe somebody had a love affair with APL???