🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2390

Re: ada-like naming scheme?

#2390
From: Richard Krehbiel
Date: Wed, 27 Mar 1996 00:55
46 lines
1885 bytes
lloyd@upsilon.cs.fsu.edu (Justin C Lloyd) wrote:

>Does anyone know how to do write a .c file so that you have to include the
>name of c file in any function calls, similar to ada?

There's no automatic way to do this.  You will have to do it by
adopting some convention.

>In ada, for instance:

>   ada.text_io.get(x);

>means there is a collection of procedures named ada (a package), and in that
>one named text_io, and in the text_io collection, one called get.

>Maybe a way to do this by putting everything in a struct? For instance...

>   float_sort.quicksort(float_array);
>   integer_sort.quicksort(int_array);
>   integer_sort.selection_sort(int_array);

You could do just that...

typedef int (*int_sort_fp)(int *), int_sort_f();
typedef int (*float_sort_fp)(float *), float_sort_f();

extern int_sort_f int_sort_quicksort;
extern float_sort_f float_sort_quicksort;

struct
{
    int_sort_fp quicksort;
} int_sort = { int_sort_quicksort };

struct
{
    float_sort_fp quicksort;
} float_sort = { float_sort_quicksort };

>From curiosity, why not just adopt a naming convention that prepends
the package/module names to the function name?  Why not simply call
them int_sort_quicksort() and float_sort_quicksort()?

--
Richard Krehbiel, Kastle Systems, Arlington VA USA
rich@kastle.com (work) or richk@mnsinc.com (personal)
Technical Details
Message-ID: <4ja3md$p5e@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4j41gd$nij@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: rich@kastle.com (Richard Krehbiel)
Newsgroups: comp.lang.c.moderated,comp.lang.c
Subject: Re: ada-like naming scheme?
Date: 26 Mar 1996 18:55:41 -0600
Organization: Kastle Development Associates
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4ja3md$p5e@solutions.solon.com>
References: <4j41gd$nij@solutions.solon.com>
Reply-To: rich@kastle.com
NNTP-Posting-Host: solutions.solon.com
X-Newsreader: Forte Free Agent 1.0.82