Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #123238

Re: NULL as the empty string

From "Pascal J. Bourguignon" <pjb@informatimago.com>
Newsgroups comp.lang.c
Subject Re: NULL as the empty string
Date 2017-11-22 00:27 +0100
Organization Informatimago
Message-ID <m2tvxnciwk.fsf@informatimago.com> (permalink)
References <ov2an8$7sq$1@dont-email.me>

Show all headers | View raw


jacobnavia <jacob@jacob.remcomp.fr> writes:

> Whaat would happen if we decide to give meaning to NULL?
>
> Assume that in all places of the string library (strlen, strcmp, etc)
> a NULL was the equivalent of the string "\0"
>
> strlen would return zero, etc. This way, we would save terabytes of
> "\0" strings since an empty string would not require any storage,
> since it is empty of course!
>
> fopen("myfile.txt",NULL) would mean that a default value would be
> chosen for file permissions, and fopen(NULL,NULL) would send all data
> to the bitbucket (a NOP) since it would return NULL. A NULL file would
> discard all output and in input it would always return EOF.
>
> NULL could mean "empty string" or "Use the default value" or many
> other useful information, using zero storage...
>
> What do you think?

Go for it:

#include <navia_lib.h>
#include <navia_str.h>

etc.

-- 
__Pascal J. Bourguignon
http://www.informatimago.com

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

NULL as the empty string jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-21 23:52 +0100
  Re: NULL as the empty string Keith Thompson <kst-u@mib.org> - 2017-11-21 15:16 -0800
    Re: NULL as the empty string jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-22 00:38 +0100
      Re: NULL as the empty string Keith Thompson <kst-u@mib.org> - 2017-11-21 16:02 -0800
        Re: NULL as the empty string jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-22 01:13 +0100
          Re: NULL as the empty string Keith Thompson <kst-u@mib.org> - 2017-11-21 16:52 -0800
      Re: NULL as the empty string Robert Wessel <robertwessel2@yahoo.com> - 2017-11-21 18:09 -0600
      Re: NULL as the empty string Siri Cruise <chine.bleu@yahoo.com> - 2017-11-21 16:34 -0800
      Re: NULL as the empty string David Brown <david.brown@hesbynett.no> - 2017-11-22 12:12 +0100
    Re: NULL as the empty string supercat@casperkitty.com - 2017-11-21 15:57 -0800
      Re: NULL as the empty string jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-22 01:06 +0100
        Re: NULL as the empty string supercat@casperkitty.com - 2017-11-22 15:42 -0800
          Re: NULL as the empty string Melzzzzz <Melzzzzz@zzzzz.com> - 2017-11-22 23:49 +0000
            Re: NULL as the empty string supercat@casperkitty.com - 2017-11-22 15:56 -0800
              Re: NULL as the empty string Melzzzzz <Melzzzzz@zzzzz.com> - 2017-11-23 00:06 +0000
                Re: NULL as the empty string supercat@casperkitty.com - 2017-11-23 17:31 -0800
                Re: NULL as the empty string jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-24 09:42 +0100
                Re: NULL as the empty string supercat@casperkitty.com - 2017-11-24 13:47 -0800
    Re: NULL as the empty string Jorgen Grahn <grahn+nntp@snipabacken.se> - 2017-11-22 06:46 +0000
  Re: NULL as the empty string supercat@casperkitty.com - 2017-11-21 15:17 -0800
    Re: NULL as the empty string jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-22 00:26 +0100
      Re: NULL as the empty string supercat@casperkitty.com - 2017-11-21 16:03 -0800
  Re: NULL as the empty string "Pascal J. Bourguignon" <pjb@informatimago.com> - 2017-11-22 00:27 +0100
    Re: NULL as the empty string jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-22 00:42 +0100
      Re: NULL as the empty string Keith Thompson <kst-u@mib.org> - 2017-11-21 16:05 -0800
  Re: NULL as the empty string Keith Thompson <kst-u@mib.org> - 2017-11-21 15:28 -0800
  Re: NULL as the empty string Thiago Adams <thiago.adams@gmail.com> - 2017-11-21 16:04 -0800
  Re: NULL as the empty string Siri Cruise <chine.bleu@yahoo.com> - 2017-11-21 16:25 -0800
    Re: NULL as the empty string jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-22 01:34 +0100
  Re: NULL as the empty string bartc <bc@freeuk.com> - 2017-11-22 00:36 +0000
  Re: NULL as the empty string Öö Tiib <ootiib@hot.ee> - 2017-11-21 23:07 -0800
  NULL as the empty string asetofsymbols@gmail.com - 2017-11-23 22:23 -0800

csiph-web