PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.c > Re: C (functional programming) VS C++ (object oriented programming)
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Re: C (functional programming) VS C++ (object oriented programming)

Réponse
 
LinkBack Outils de la discussion
Vieux 17/10/2007, 12h00   #1
Charlie Gordon
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: C (functional programming) VS C++ (object oriented programming)

"Richard" <rgrdev@gmail.com> a écrit dans le message de news:
56uht4-gb6.ln1@news.individual.net...
> "Charlie Gordon" <news@chqrlie.org> writes:
>
>> "Richard" <rgrdev@gmail.com> a écrit dans le message de news:
>> ftaft4-tni.ln1@news.individual.net...
>>> santosh <santosh.k83@gmail.com> writes:
>>>
>>>> Joe Mayo wrote:
>>>>
>>>>> jacob navia schrieb:
>>>>>> ...
>>>>>> No abstraction, low level, dangerous procedures like strncpy
>>>>> > ...
>>>>>
>>>>> What is dangerous on strncpy?
>>>>> Is strcpy not much more dangerous than strncpy?
>>>>
>>>> Both are dangerous only when misused. In addition strncpy has a
>>>> possibly
>>>> misleading name, which is really what , I suspect, jacob was referring
>>>> to.
>>>
>>> The reply above is valid for ANY form of C programming.
>>>
>>> i=i++
>>>
>>> can be potentially lethal too if you dont know what you are doing.
>>>
>>> For gods sake, leave strncpy alone. It does what it is documented to do.
>>>
>>> strtok and gets are the ones to diss.

>>
>> strtok and gets also do what they are documented to do, yet you agree
>> they
>> should be deprecated.

>
> I dont agree any suhc thing. But they are fatally flawed.
>
>> strncpy is so easy to misuse and so widely misused that it should be more
>> actively scrutinized.

>
> You are either a very bad programmer or a troll. Sorry but strncpy does
> what the documentation says. The fact that you seem unwilling or
> incapable of using it correctly has become a tad boring to be honest.


These are false accusations: I know perfectly well what strncpy does and am
quite capable of using it correctly. In my projects, I have never seen a
single place where its semantics were appropriate. strncpy has never been
"the right thing", contrary to strlcpy. My "boring" persistence at warning
other programmers about strncpy is a pedagogical move : so many "savvy"
regulars on c.l.c seem unable to grasp the concept of "error prone" and "too
easy to misuse".

>> A compiler warning seems appropriate for all of them.

>
> Bullshit. Would you like a compiler warning when incrementing a pointer
> too in case the programmer forgets to keep it pointing to valid memory?


If the compiler can determine that the pointer is incremented beyond the
border of the array, a warning seems appropriate to me. I the pointer is
known to be NULL, a warning is definitely useful:

char *p = NULL;
char *q = p++; /* please tell me this is bogus! */

--
Chqrlie.


  Réponse avec citation
Vieux 17/10/2007, 13h04   #2
jacob navia
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: C (functional programming) VS C++ (object oriented programming)

Charlie Gordon wrote:
[snip]
> I know perfectly well what strncpy does and am
> quite capable of using it correctly. In my projects, I have never seen a
> single place where its semantics were appropriate. strncpy has never been
> "the right thing", contrary to strlcpy. My "boring" persistence at warning
> other programmers about strncpy is a pedagogical move : so many "savvy"
> regulars on c.l.c seem unable to grasp the concept of "error prone" and "too
> easy to misuse".


This is exactly the problem. If an interface is consistently misused
this doesn't mean that all programers are stupid but that is BADLY
DESIGNED!

The C library was designed around 30 years ago and this shows!


--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 23h39.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08681 seconds with 10 queries