
C gibberish to  English - naryad
http://cdecl.org/
======
geofft
This seems to be the same as the cdecl program available in most Linux
distributions (apt-get install cdecl).

Websites for these little utilities are definitely useful, though. :)

~~~
michaelcampbell
Indeed. It is quite old. I remember using the CLI version of this that I had
to compile on my own in the early 90's on Solaris 2.x on a Sparc.

------
shurcooL
Neat site!

    
    
        // declare foo as pointer to function (void) returning pointer to array 3 of int
        int (*(*foo)(void ))[3]
    

That's actually a great example to throw at Go's syntax, which if you read
from left-to-right, is perfectly one-to-one with the english:

    
    
        // declare foo as pointer to function (void) returning pointer to array 3 of int
        var foo *func() *[3]int
    

[http://play.golang.org/p/1b48cjmZbx](http://play.golang.org/p/1b48cjmZbx)

------
jankins
This is a great helper for getting acquainted with the C spiral rule:
[http://c-faq.com/decl/spiral.anderson.html](http://c-faq.com/decl/spiral.anderson.html)

~~~
stephencanon
I've said it before
([http://news.ycombinator.com/item?id=5080096](http://news.ycombinator.com/item?id=5080096)),
I'll say it again: the "spiral rule" makes pretty pictures, but it's nonsense.

------
k4st
I also find this online utility useful when I don't have c++filt (another
program available to Linux distros) available:

[http://pear.warosu.org/c++filtjs/](http://pear.warosu.org/c++filtjs/)

This can be used to demangle C++ names.

------
coherentpony
Maybe it's just me but having it written in English doesn't actually help me
understand complex declarations.

------
brianmwaters_hn
I'm really surprised nobody's mentioned that this is an exercise from K&R
(a.k.a. "The C Programming Language"), a must-read for any C programmer!

[https://en.wikipedia.org/wiki/The_C_Programming_Language](https://en.wikipedia.org/wiki/The_C_Programming_Language)

------
JoshTriplett
This has some odd corner cases.

"void f(void)" -> "declare f as function (void) returning void"

"void fun(void)" -> "declare fun as function (void) returning void"

"void funct(void)" -> "declare funct as function (void) returning void"

"void func(void)" -> "syntax error"

"func" is not a special name in C.

Also:

"void fn(void f(void))" -> "syntax error"

But this syntax works just fine:

    
    
        /tmp$ cat test.c
        #include <stdio.h>
        
        void fn(void f(void))
        {
            f();
            f();
        }
        
        void g(void)
        {
            puts("g");
        }
        
        int main()
        {
            fn(g);
            return 0;
        }
        /tmp$ gcc test.c
        /tmp$ ./a.out
        g
        g

~~~
nknighthb
Not sure what's going on with your second example, but that first one looks
like an odd consequence of how a cdecl feature is implemented. cdecl doesn't
just explain C declarations, it can also create them based on a more verbose
pseudo-english language (the same one it spits out in response to being fed an
actual C declaration, I believe). "func" is an alias for that language's
reserved word "function".

------
Keyframe
the hell is this witchcraft?
[http://cdecl.ridiculousfish.com/?q=cast+foo+into+block%28int...](http://cdecl.ridiculousfish.com/?q=cast+foo+into+block%28int%2C+long+long%29+returning+double)

~~~
MaxGabriel
Apple extension to C language for blocks/lambdas.
[http://en.wikipedia.org/wiki/Blocks_(C_language_extension)](http://en.wikipedia.org/wiki/Blocks_\(C_language_extension\))

~~~
Keyframe
Tat explains it why I haven't seen it then. I was afraid there for a second I
was losing my mind.

------
RossPenman
C gibberish to English gibberish.

------
mistercow
I wonder how difficult it would be to write a C compiler (probably using LLVM
would make sense) that translates an entire C program into English.

~~~
NAFV_P
A C compiler that converts C to English is not a compiler

~~~
mistercow
Pointless semantics.

------
BlobbleBlab
For most programmers, the C notation is probably easier to read / understand
than the English gibberish derived from it with this tool

------
roryokane
Note that this is “C gibberish _↔_ English”, not just “to English”. So it also
converts (specially-formatted) English to C gibberish. The second and third
examples at the top demonstrate this feature.

------
fishpi
I did something like this using C++ template metaprogramming, which means you
can make use of the compiler to figure out the types for you, and you just
have to write class templates to produce the English description. It's
described at [http://blog.asymptotic.co.uk/2011/02/c-type-declaration-
deco...](http://blog.asymptotic.co.uk/2011/02/c-type-declaration-decoder/) ,
although somewhere along the line the markup got corrupted so the code samples
don't quite render correctly.

------
jcox92
I'm a fan of the 'c-spiral' rule/
[http://c-faq.com/decl/spiral.anderson.html](http://c-faq.com/decl/spiral.anderson.html)

------
KiwiCoder
Cool idea, although I expect everyone who understands the English version
would also have understood the C version.

------
TorKlingberg
Cdecl is quite useful, but it does not work if you have declared your own
types.

"Foo a" declares a of type Foo (whatever that is), but cdecl says Syntax
Error.

It does not even work with C99 types. "bool a", "_Bool a", "int32_t a" all
give Syntax Error.

------
mjburgess
"I guess this'll be used mainly for function pointers"... first example.

------
justinhj
I'd like to see an equivalent for parsing common shell commands and their
arguments. Just converting the short form to the long form would be a good
start

------
Madrigal
It can be a useful tool to get the main "feeling" in a complex line of
pointers, but I wouldn't use it to auto-generate explainer comments

------
nraynaud
too bad it doesn't accept statements, I would be glad to get its take on a
Duff's device.

~~~
jloughry
Should anyone take this on (to write a version of cdecl that translates
statements to English) as a personal challenge, please consider making it
adaptable to whatever language is currently in fad for teaching beginning
programming. This could be an _extremely_ useful tool for teachers.

------
tbyehl
I need a regex version of this.

