Language:
switch to room list switch to menu My folders
Go to page: First ... 56 57 58 59 [60] 61 62 63 64 ... Last
[#] Sun May 16 2010 14:59:25 EDT from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

me realy likes strongly typed languages. Having coded php for several years, starting to code c again was like getting rid of chewingum clogging up my brain.

I realy like const. Though it has some limitations with pure c: a function like strchr can't be there once with const, once without; its one of the fixes doable with it...

yea, one of the shortcommings of c.

 



[#] Mon May 17 2010 13:57:32 EDT from Spell Binder @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

One of the things about const that trips me up is how it acts in regards to pointers.

For example--and I'm a little fuzzy on this, so I may have things backwards--this declaration:

const char *foo;

Declares foo as a pointer to a character that is read-only.

However:

char *foo = "Hello world!\n";
char const *bar = foo;

Declares foo as a pointer to a character that can be read or written, but the pointer itself is read-only.

And then:

char *foo = "Hello world!\n";
const char const *bar = foo;

Declares foo as a read-only pointer to a read-only character.

It just seems a little wonky to me.
const char *Spell = Binder;

[#] Mon May 17 2010 14:17:44 EDT from Peter Pulse @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Since I avoid const, I'm certainly no expert. But.. I kinda see some logic here.. a "char *" is a pointer (*) to a char (char). * is the type of the immediate storage, char is the type of data it points to. Now ok, I know what you are gonna say.. you can't count on a pointer to one type being able to point to another type.. that is an implementation detail we are not supposed to know about. So, there is no such thing as a "*".. "char *" is atomic.
I will grant you that. Though the addition of void * to C muddled that rule.
But semantically, for the purposes of the const declaration, it kinda makes sense.

[#] Mon May 17 2010 14:59:04 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]



I think it boils down to a question of the grammar's associativity. "*" is left-associative.

[#] Mon May 17 2010 15:06:47 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


Or is that right-associative? Anyway, you read it starting at the pointer and looking left.

[#] Mon May 17 2010 15:14:34 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


There are a whole class of readability issues in C that can be mitigated with typedefs. This is one of them.


typedef char_ptr char *;
const char_ptr foo; // same as "char * const*" ;)

It gets worse with function pointers, and typedefs are even more helpful there.

I can see the advantage in languages that declare functions as:

(ArgTypes) -> ReturnType (such as Scala, Haskell, C# closures, etc..)

Functions return pointers to functions are simplified:

(Arg<Type) -> (ArgType) -> ReturnType


In C this would look like:

(ReturnType (*)(ArgType)) foo (ArgType)

Which is pretty darn ugly, and wants a typedef just for clarity.

[#] Mon May 17 2010 16:14:04 EDT from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I also like strongly typed languages, and I'm usually in favor of things that help. I do mostly like the way generics work in java (especially since e eclipse does all the extra typing for me) but they really overloaded the word const too much.
you can have const that means the value doesn't change, you can have const that means the pointed to value doesn't change, you can have const that means as ls pointed out and I forgot that the function doesn't change anything, and I vaguely recall there's a few more. I haven't written real C++ in years so I'm getting rusty quickly, but if they had used other keywords for these varoius things it might have made it easier to follow.

[#] Mon May 17 2010 16:15:05 EDT from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I still think REXX scores highest for lax typing...

print hi

hi


hi = 42

print hi

42

[#] Mon May 17 2010 17:46:04 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


ford, what's going on in the first line of that example?

Does it implicitly declare a variable named "hi" and set the value (also implicitly) to "hi", or is hi not a variable, but a string literal, until it's assigned?

Either way: forgiving like INTERCAL.

[#] Tue May 18 2010 07:52:48 EDT from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

did some experimenting with clang and clang++; had to compile from source since theres no clang++ .deb, but I realy like the error messages and warnings it generates.

Thats the way it should have been in the first place.



[#] Tue May 18 2010 10:38:59 EDT from Spell Binder @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Re: REXX and variables.

If I remember correctly (and it's been a while), the first line in Ford's example will create a variable named "hi" and initialize it with the variable's name as its value.

The Wikipedia article about REXX agrees:

http://en.wikipedia.org/wiki/Rexx

I should dig out my old REXX book and bring it in to see how many formers IBMers I can trap. Muahahahahahaha!
REXX Binder

[#] Tue May 18 2010 10:49:20 EDT from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Does it implicitly declare a variable named "hi" and set the value
(also implicitly) to "hi", or is hi not a variable, but a string
literal, until it's assigned?

No, simpler than that. If a string of text doesn't resolve as a variable it is treated as a string literal, it doesn't implicitly make it one, although the effect is the same.

[#] Tue May 18 2010 10:50:42 EDT from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I stand corrected, I remembered that it just used it as the string literal without creating the variable.

[#] Tue May 18 2010 10:51:41 EDT from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

did some experimenting with clang and clang++; had to compile from

"Such a horrid clang"

And what value does clang++ bring to the table that g++ does not?

[#] Tue May 18 2010 11:15:23 EDT from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

a searchterm next to ungooglabe like oracle proC or LaTeX ;-)

its working as frontend to the LLVM backend; Its not yet able to do full boost magic, but getting there.

here are some of its warning (the ^ gets a little out of bearing through the html, but its all in place in an xterm.

 

clang -g -O2 -Wall -Wcast-qual -Wcast-align -Wstrict-prototypes -D_REENTRANT -pthread -I ./include/ -I. -I ./include/ -DHAVE_CONFIG_H -c utillib/citadel_ipc.c -o utillib/citadel_ipc.o
utillib/citadel_ipc.c:2098:2: warning: expression result unused [-Wunused-value]
BIO_set_close(ipc->ssl->rbio, BIO_NOCLOSE);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from utillib/citadel_ipc.c:51:
In file included from ./include/citadel_ipc.h:16:
In file included from /usr/include/openssl/ssl.h:179:
/usr/include/openssl/bio.h:510:28: note: instantiated from:
#define BIO_set_close(b,c)      (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)
^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
utillib/citadel_ipc.c:3248:40: warning: format string is not a string literal (potentially insecure)
[-Wformat-security]
snprintf(sockpath, sizeof sockpath, file_citadel_socket);
^~~~~~~~~~~~~~~~~~~
2 warnings generated.

clang -g -O2 -Wall -Wcast-qual -Wcast-align -Wstrict-prototypes -D_REENTRANT -pthread -I ./include/ -I. -I ./include/ -DHAVE_CONFIG_H -c textclient/screen.c -o textclient/screen.o
textclient/screen.c:92:3: warning: expression result unused [-Wunused-value]
mvwinch(statuswindow, 0, screenwidth - 2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from textclient/screen.c:29:
In file included from textclient/screen.h:7:
/usr/include/ncurses.h:1211:52: note: instantiated from:
#define mvwinch(win,y,x)                (wmove(win,y,x) == ERR ? NCURSES_CAST(chtype, ERR) : winch(win))
^
/usr/include/ncurses.h:196:34: note: instantiated from:
#define NCURSES_CAST(type,value) (type)(value)
^     ~~~~~~~
textclient/screen.c:288:5: warning: expression result unused [-Wunused-value]
mvwinch(statuswindow, 0, 0);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from textclient/screen.c:29:
In file included from textclient/screen.h:7:
/usr/include/ncurses.h:1211:52: note: instantiated from:
#define mvwinch(win,y,x)                (wmove(win,y,x) == ERR ? NCURSES_CAST(chtype, ERR) : winch(win))
^
/usr/include/ncurses.h:196:34: note: instantiated from:
#define NCURSES_CAST(type,value) (type)(value)
^     ~~~~~~~
textclient/screen.c:320:5: warning: expression result unused [-Wunused-value]
mvwinch(statuswindow, 0, 0);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from textclient/screen.c:29:
In file included from textclient/screen.h:7:
/usr/include/ncurses.h:1211:52: note: instantiated from:
#define mvwinch(win,y,x)                (wmove(win,y,x) == ERR ? NCURSES_CAST(chtype, ERR) : winch(win))
^
/usr/include/ncurses.h:196:34: note: instantiated from:
#define NCURSES_CAST(type,value) (type)(value)
^     ~~~~~~~
3 warnings generated.
clang -g -O2 -Wall -Wcast-qual -Wcast-align -Wstrict-prototypes -D_REENTRANT -pthread -I ./include/ -I. -I ./include/ -DHAVE_CONFIG_H -c utillib/citadel_dirs.c -o utillib/citadel_dirs.o
utillib/citadel_dirs.c:124:48: warning: format string is not a string literal (potentially insecure)
[-Wformat-security]
snprintf(ctdl_sbin_dir, sizeof ctdl_sbin_dir, ctdldir);
^~~~~~~
utillib/citadel_dirs.c:125:46: warning: format string is not a string literal (potentially insecure)
[-Wformat-security]
snprintf(ctdl_bin_dir, sizeof ctdl_bin_dir, ctdldir);
^~~~~~~
2 warnings generated.



[#] Tue May 18 2010 18:57:33 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


Yeah, that REXX example should definitely win some sort of perversity award.

[#] Fri May 21 2010 07:30:19 EDT from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

so we've got a new kid in town:

http://blog.llvm.org/2010/05/clang-builds-boost.html

as egcs showed way back open source monopolies aren't good either.



[#] Sat May 22 2010 10:42:40 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


ooops, looks like you "can't apply generic programming" in C++ ;)



http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm

[#] Wed May 26 2010 10:44:47 EDT from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

so... multipart mime chunked http replies have to have the mime headers at the start of a chunk.

a little easier to find out with bash & netcat instead of real c-coding...



[#] Wed May 26 2010 10:54:07 EDT from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

really? chunking is a lower level protocol thing, it is unaware of mime-ness.
That doesn't sound right.

Go to page: First ... 56 57 58 59 [60] 61 62 63 64 ... Last