473,789 Members | 2,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UNIX, C, Perl

Given that UNIX, including networking, is almost entirely coded in C,
how come so many things are almost impossible in ordinary C? Examples:
Network and internet access, access to UNIX interprocess controls and
communication, locale determination, EBCDIC/ASCII discrimination, etc.

Almost all of these are easy in Perl. Why isn't there a mechanism like
perl modules to allow easy extentions for facilities like these? Isn't
anyone working on this problem? or is it all being left for proprietary
systems?
Sep 2 '08
223 7382
Richard wrote:
Ben Bacarisse <be********@bsb .me.ukwrites:
>Richard<rg**** @gmail.comwrite s:
>>ja*********@ver izon.net writes:

Richard wrote:
ja*********@ver izon.net writes:
<snip>
>>>>>While such a suggestion is on-topic in that group, it is still not the
>right place to make your proposal.
<snip>
>>>>All may be true. But to discuss it here is easily the best thing to do
since real programmers can dissect ideas "in the real world".
But he doesn't want his ideas dissected - the only thing he's open to
is unthinking uncritical acceptance of the "fact" that his ideas are
both sufficiently good that they should be approved without
modification , and sufficiently important that they should be approved
immediatel y. Present him with any disagreement, no matter how trivial,
and all you'll receive in response is a stream of vituperation.
Total and utter nonsense.

He rises to Heathfield's arrogant posturing now and again but more often
than not Jacob is willing to discuss.
Odd, then, that your contribution to this mature debate was:

| I would sooner boil my nuts in a vat of sun flower oil than agree
| that operator overloading in C is a good idea.

to which Jacob simply suggested supplying an alternative oil. Why did
you not think Jacob would be receptive to a more technical critique at
the time?

Its called a joke. We had discussed it before and I explained my
"practical" objections to operator overloading in any language. i
realise I am in a minority. I remember when I thought they were
"kewl". Then I had to maintain and extend poorly written code which
absolutely thrashed the use of them. It was horrific.

*Anything* can be misused Richard, and operator overloading is no
exception.

The main application domain I see is the capacity of defining new types
of numerical data in C and keep the infix notation. You can't argue that
complicated fromula are more easily written using the notation we
learned at school.

It *is* easier to write
c = a+b
than c = sum(a,b);

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Sep 6 '08 #131
jacob navia said:

<snip>
The main application domain I see [for operator overloading] is the
capacity of defining new types
of numerical data in C and keep the infix notation. You can't argue that
complicated fromula are more easily written using the notation we
learned at school.

It *is* easier to write
c = a+b
than c = sum(a,b);
100% agreed. (And this is *me* saying it!)

I'm trying to work out how it would work for strings. It would be great to
be able to say s = t + u instead of sprintf(s, "%s%s", t, u) and s = t + n
instead of sprintf(s, "%s%d", t, n) - but that's going to make for an
almighty clash with ordinary pointer arithmetic. Any ideas?

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 6 '08 #132
jacob navia <ja***@nospam.c omwrites:
Richard wrote:
>Ben Bacarisse <be********@bsb .me.ukwrites:
>>Richard<rg*** *@gmail.comwrit es:

ja*********@ver izon.net writes:

Richard wrote:
>ja*********@ver izon.net writes:
<snip>
>>While such a suggestion is on-topic in that group, it is still not the
>>right place to make your proposal.
<snip>
>All may be true. But to discuss it here is easily the best thing to do
>since real programmers can dissect ideas "in the real world".
But he doesn't want his ideas dissected - the only thing he's open to
is unthinking uncritical acceptance of the "fact" that his ideas are
both sufficiently good that they should be approved without
modificatio n, and sufficiently important that they should be approved
immediately . Present him with any disagreement, no matter how trivial,
and all you'll receive in response is a stream of vituperation.
Total and utter nonsense.

He rises to Heathfield's arrogant posturing now and again but more often
than not Jacob is willing to discuss.
Odd, then, that your contribution to this mature debate was:

| I would sooner boil my nuts in a vat of sun flower oil than agree
| that operator overloading in C is a good idea.

to which Jacob simply suggested supplying an alternative oil. Why did
you not think Jacob would be receptive to a more technical critique at
the time?

Its called a joke. We had discussed it before and I explained my
"practical" objections to operator overloading in any language. i
realise I am in a minority. I remember when I thought they were
"kewl". Then I had to maintain and extend poorly written code which
absolutely thrashed the use of them. It was horrific.


*Anything* can be misused Richard, and operator overloading is no
exception.

The main application domain I see is the capacity of defining new types
of numerical data in C and keep the infix notation. You can't argue that
complicated fromula are more easily written using the notation we
learned at school.

It *is* easier to write
c = a+b
than c = sum(a,b);
It is. Its also easier to type

a=f(a,z) than

total=sumOfTwoC oordinates(y1,y 2); /* totally made up example but try to
get the drift .. */

I know which makes more sense and is easier to read and debug. Yes, yes,
I know c.l.c regs don't debug because Kernighan once said its easier to
do it right the first time than to have to debug it later but, well,
we're not all Richard Heathfields or Chuck Falconers.
Sep 6 '08 #133
Richard Heathfield <rj*@see.sig.in validwrites:
jacob navia said:

<snip>
>The main application domain I see [for operator overloading] is the
capacity of defining new types
of numerical data in C and keep the infix notation. You can't argue that
complicated fromula are more easily written using the notation we
learned at school.

It *is* easier to write
c = a+b
than c = sum(a,b);

100% agreed. (And this is *me* saying it!)
But little thought is put into the example here.

Yes, it is easier. Especially when below is an example of it fully
extrapolated to a function call.

But what is easier in this instance?

i=a+b;

or

struct cursorPos=moveC ursorRelative(x delta,ydelta);

Really, I have been there done that. I never found anything worse in
code than operator overloading. It *does* get mis used. You can not read
the code properly from a print out IMO. Nightmare. So, basically I am
still to be convinced.
>
I'm trying to work out how it would work for strings. It would be great to
be able to say s = t + u instead of sprintf(s, "%s%s", t, u) and s = t + n
instead of sprintf(s, "%s%d", t, n) - but that's going to make for an
almighty clash with ordinary pointer arithmetic. Any ideas?
And integer arithmetic and anything else that uses "+" when you are
reading the code .....
Sep 6 '08 #134

"Richard Heathfield" <rj*@see.sig.in validwrote in message
news:PN******** *************** *******@bt.com. ..
jacob navia said:

<snip>
>The main application domain I see [for operator overloading] is the
capacity of defining new types
of numerical data in C and keep the infix notation. You can't argue that
complicated fromula are more easily written using the notation we
learned at school.

It *is* easier to write
c = a+b
than c = sum(a,b);

100% agreed. (And this is *me* saying it!)

I'm trying to work out how it would work for strings. It would be great to
be able to say s = t + u instead of sprintf(s, "%s%s", t, u) and s = t + n
instead of sprintf(s, "%s%d", t, n) - but that's going to make for an
almighty clash with ordinary pointer arithmetic. Any ideas?
t + u is addition of two pointers, which has at present no meaning in C.

t + n adds an integer to a pointer, and would be a problem, but it's not
unreasonable to require a conversion, eg: t + str(n).

More difficult is how to deal with the implicit memory handling which needs
to be done:

a = b + c + d + e

You might be able to do free(a), but what about the intermediate strings?
The whole thing is very un-C-like.

--
Bartc

Sep 6 '08 #135
"Bartc" <bc@freeuk.comw rites:
"Richard Heathfield" <rj*@see.sig.in validwrote in message
news:PN******** *************** *******@bt.com. ..
>jacob navia said:

<snip>
>>The main application domain I see [for operator overloading] is the
capacity of defining new types
of numerical data in C and keep the infix notation. You can't argue that
complicated fromula are more easily written using the notation we
learned at school.

It *is* easier to write
c = a+b
than c = sum(a,b);

100% agreed. (And this is *me* saying it!)

I'm trying to work out how it would work for strings. It would be great to
be able to say s = t + u instead of sprintf(s, "%s%s", t, u) and s = t + n
instead of sprintf(s, "%s%d", t, n) - but that's going to make for an
almighty clash with ordinary pointer arithmetic. Any ideas?

t + u is addition of two pointers, which has at present no meaning in C.

t + n adds an integer to a pointer, and would be a problem, but it's
not unreasonable to require a conversion, eg: t + str(n).

More difficult is how to deal with the implicit memory handling which
needs to be done:

a = b + c + d + e

You might be able to do free(a), but what about the intermediate
strings? The whole thing is very un-C-like.
Exactly. And it opens up entire "paradigm shifts" which would lead to a
mess. Keep C as C.
Sep 6 '08 #136
Richard Heathfield wrote:
jacob navia said:

<snip>
>The main application domain I see [for operator overloading] is the
capacity of defining new types
of numerical data in C and keep the infix notation. You can't argue that
complicated fromula are more easily written using the notation we
learned at school.

It *is* easier to write
c = a+b
than c = sum(a,b);

100% agreed. (And this is *me* saying it!)

I'm trying to work out how it would work for strings. It would be great to
be able to say s = t + u instead of sprintf(s, "%s%s", t, u) and s = t + n
instead of sprintf(s, "%s%d", t, n) - but that's going to make for an
almighty clash with ordinary pointer arithmetic. Any ideas?
1) I am not convinced that addition is the right operator for string
concatentation since if we use it for strings:
a+b != b+a
Normally we treat addition as commutative...

2) The problem with addition of pointer with integer is that this
operation is already defined and has a well defined meaning
in C. That is why lcc-win does NOT allow you to redefine it
to give it a new meaning. The reasons are many mainly:
(a) Existing code becomes ambiguous.
(b) It is impossible to address a character beyond the
start of a string...

Look Mr Heathfield, you know this by heart, and it is really not very
helpful to just play games and pose "clever" questions...

It would be *much* more helpful if you would help with the *real*
problems with this stuff...

(1) How do you overload the '[' ']' operators with multidimensiona l
arrays? This is not possible with C++. I think that a syntax like
(1) TYPE operator [][](TYPE table,int line,int column)
{ ... }
(2) TYPE operator [2](TYPE table,int line, column)
{ ... }

Or just the same notation as for the normal operator { ] with
more indices:
(3) TYPE operator [](TYPE table, int plane, int line, int column)

(2)
How to overload the ++ operator to distinguish from pre-increment
and post increment?
I would propose
TYPE ++operator(TYPE s) // for pre-increment
TYPE operator++(TYPE s) // for post-increment

but I am not sure of this.

There are several open issues like those.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Sep 6 '08 #137
jacob navia <ja***@nospam.c omwrites:
Richard Heathfield wrote:
>jacob navia said:

<snip>
>>The main application domain I see [for operator overloading] is the
capacity of defining new types
of numerical data in C and keep the infix notation. You can't argue that
complicated fromula are more easily written using the notation we
learned at school.

It *is* easier to write
c = a+b
than c = sum(a,b);

100% agreed. (And this is *me* saying it!)

I'm trying to work out how it would work for strings. It would be
great to be able to say s = t + u instead of sprintf(s, "%s%s", t,
u) and s = t + n instead of sprintf(s, "%s%d", t, n) - but that's
going to make for an almighty clash with ordinary pointer
arithmetic. Any ideas?

1) I am not convinced that addition is the right operator for string
concatentation since if we use it for strings:
a+b != b+a
Normally we treat addition as commutative...

2) The problem with addition of pointer with integer is that this
operation is already defined and has a well defined meaning
in C. That is why lcc-win does NOT allow you to redefine it
to give it a new meaning. The reasons are many mainly:
(a) Existing code becomes ambiguous.
(b) It is impossible to address a character beyond the
start of a string...

Look Mr Heathfield, you know this by heart, and it is really not very
helpful to just play games and pose "clever" questions...
Its what he does. And he likes to seed Google with names (although
wrong) too I see!
>
It would be *much* more helpful if you would help with the *real*
problems with this stuff...
No chance. He is playing "friend" to appear to the casual observer that
he doesn't in fact hate your guts. And it is quite clear to anyone who
reads this newsgroup that he does indeed hate your guts. Very
un-christian like but most god botherers I have known have had similar
tendencies.

Sep 6 '08 #138
Bartc said:
Richard Heathfield wrote:
<snip>
>>
I'm trying to work out how it would work for strings. It would be great
to be able to say s = t + u instead of sprintf(s, "%s%s", t, u) and s =
t + n instead of sprintf(s, "%s%d", t, n) - but that's going to make for
an almighty clash with ordinary pointer arithmetic. Any ideas?

t + u is addition of two pointers, which has at present no meaning in C.
Yeah, actually I thought a bit after hitting Send (always the way, ain't
it?), and it occurred to me that it /couldn't/ work for C strings, but it
could work for a new type, xstring or whatever.
t + n adds an integer to a pointer, and would be a problem, but it's not
unreasonable to require a conversion, eg: t + str(n).
But this would work:

xstring s, t;
t = "come in, number ";
s = t + 42;
s += "; your time is up.";

provided we didn't ever want to treat xstring as a pointer.
More difficult is how to deal with the implicit memory handling which
needs to be done:

a = b + c + d + e

You might be able to do free(a),
No, because 'a' wouldn't be a simple pointer - it would need to be an
object (in the C sense at the very least) that contains a certain amount
of state, so I think we're going to need a destructor of some kind. Ah,
this is where the C++ pollution begins, I see.
but what about the intermediate strings?
You would handle those the same way you handle intermediate values in f = 1
+ 2 + 3 + 4 + 5 in current C.
The whole thing is very un-C-like.
Yes. It's beginning to look remarkably C++-like, though.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 6 '08 #139
Malcolm McLean wrote:
>
"jacob navia" <ja***@nospam.c omwrote in message
>(2)
How to overload the ++ operator to distinguish from pre-increment
and post increment?
I would propose
TYPE ++operator(TYPE s) // for pre-increment
TYPE operator++(TYPE s) // for post-increment
What a nightmare.

++obj will do something subtly different to obj++.
Can you explain a bit?

Because with
int a = 23;

++a does something subtly different than a++.
I'd keep the C rules
of precedence and binding, and define that the operations are always
identical otherwise.
I do not see how precedence rules are changed sorry. Maybe can you explain?
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Sep 6 '08 #140

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6557
by: dpackwood | last post by:
Hello, I have two different scripts that do pretty much the same thing. The main perl script is on Windows. It runs and in the middle of it, it then calls out another perl script that then should run on a Unix box I have. Both scripts run ok, except for the part when Windows try's to call out the Unix script. I have it set up where the Unix is mapped through a drive letter and can drop stuff into the Unix box. It is going through another...
2
5673
by: Mohsin | last post by:
Hi all, I have a perl program which makes a user exit to the O/S (unix, solaris) to issue a O/S command. I know that the shell it invokes is NOT a korn shell, because I captured the shell info into a file with a 'ps' command. My question is "How to explicitly specify a Korn shell to be used by perl?" Eg of my perl code: ## Begin code snippet..
0
6448
by: Danny Jensen | last post by:
I need to test if certain processes on a unix box were running. I wanted to use whatsup gold to do the testing. First I needed to go to the whatsup configure>monitors & services menu to add this tcp/ip port 1555 service with the folowing lines: Send=psef /dj/myco/rf.monitor\r\n Expect=~1 the psef above is a command that the unix server executes. The unix box communicates back a 1 if the test is successful and a 0 if it is
1
17721
by: Al Belden | last post by:
Hi all, I've been working on a problem that I thought might be of interest: I'm trying to replace some korn shell scripts that search source code files with perl scripts to gain certain features such as: More powerful regular expressions available in perl Ability to print out lines before and after matches (gnu grep supports this but is not availble on our Digital Unix and AIX platforms) Make searches case insensitive by default (yes, I...
6
1671
by: asimorio | last post by:
Hi folks, Recently, I am investigatin a memory leak issue. I have written a simple C++ program and a Perl script to test on UNIX environment machine. I do a for loop to new up 20 char of size 32768 bytes, then delete them. Please see below: //// part of the code start //// for (i=0; i<20; i++) { ptrA = new (std::nothrow) char;
2
4275
by: perlnewbie | last post by:
Hi everyone I am new to perl and I am writing a perl script to invoke a set of commands on UNIX clearcase vob however I am having trouble after setting the view and mounting the vob I want to change the directory into the vob and then using Cwd or pwd to confirm I am in the vob to continue the CC functions. Sample code in perl : $Result = system 'cleartool setview admin_view'; $Result = system ('cleartool mount /vobs/test');
4
3792
by: jane007 | last post by:
Hello everybody: I am having a problem. On Unix platform, there is a script that need user to input data from console, then when I call Unix perl script from Windows, these is an issue occurs, when I input data and enter "enter" so fast, the Windows console is freezed, I don't know why, does anybody know?Thank you very much. My code like follows:
4
4274
by: mdshafi01 | last post by:
Hi , I am trying to send mail from unix perl. I am using following code to send mail. It is not triggering mail and also it is not giving any error. please tell me any special settings are required or this program should be executed from special user with higher permission or something. please tell me.
1
3983
by: dxz | last post by:
I have a perl script to run on both UNIX and Windows. How should I write the Shabang line: On UNIX, it is #!/usr/bin/perl On Windows, it is #!C:\perl\bin\perl.exe Which one should I use? Should I combine them? If yes, how?
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10404
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9016
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6765
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.