473,889 Members | 1,927 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C Syntax

Why is C syntax so uneasy on the eye?

In its day, was it _really_ designed by snobby programmers to scare away
potential "n00bs"? If so, and after 50+ years of programming research,
why are programming languages still being designed with C's syntax?

These questions drive me insane. Every waking minute...
Nov 14 '05
177 7144
In <sl************ ****@ID-227112.user.uni-berlin.de> Sam Dennis <sa*@malfunctio n.screaming.net > writes:
Dan Pop wrote:
[In VIM]
Set sw=4 and leave ts to its default value of 8. Open a new file,
enter insert mode and type " alpha". Save the file and check that
the hand input spaces are there:


Of course.
Reopen the file, with the same vi settings and use the shift right
command, then save the file and check that the hand input spaces are
gone.

The behaviour is consistent between vim on Linux and vi on Solaris, BTW.


Not here; I have 'expandtab' set by default. While there may not be a
universal solution for all vi clones, that's no reason to ignore those
presented by the individual editors you use.


It certainly is, when you expect *consistent* behaviour from vi on all
platforms. The *last* thing I want to do when using vi is remembering on
which platform I am and what is the right solution for my problem.

It is already bad enough that Solaris comes with an ancient, BSD-style
vi that doesn't recognise the cursor keys in input mode...

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #161
Da*****@cern.ch (Dan Pop) writes:
[...]
It certainly is, when you expect *consistent* behaviour from vi on all
platforms. The *last* thing I want to do when using vi is remembering on
which platform I am and what is the right solution for my problem.

It is already bad enough that Solaris comes with an ancient, BSD-style
vi that doesn't recognise the cursor keys in input mode...


You might consider downloading one of the free vi clones (vim, nvi,
whatever) and building it on Solaris -- though that might not be
practical if you jump around to various machines.

(Way OT: strictly speaking, nvi isn't a vi clone; it's the direct
descendant of the original vi.)

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #162
In article <ca**********@s unnews.cern.ch> Da*****@cern.ch (Dan Pop) writes:
In <sl************ ****@ID-227112.user.uni-berlin.de> Sam Dennis <sa*@malfunctio n.screaming.net > writes: ....
Not here; I have 'expandtab' set by default. While there may not be a
universal solution for all vi clones, that's no reason to ignore those
presented by the individual editors you use.


It certainly is, when you expect *consistent* behaviour from vi on all
platforms. The *last* thing I want to do when using vi is remembering on
which platform I am and what is the right solution for my problem.


Wrong. You expect consistent behaviour from vi and vim, two completely
different programs. That vim is called vi on some platforms is irrelevant.
It is already bad enough that Solaris comes with an ancient, BSD-style
vi that doesn't recognise the cursor keys in input mode...


Why, exactly, is this bad? And to be sure, I know of only one vi, the old
BSD-style one. Others are clones under different names. This is similar
to complaining that cc under Solaris does not do exactly the same as cc
under Linux.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Nov 14 '05 #163
In article <ca**********@s unnews.cern.ch> Da*****@cern.ch (Dan Pop) writes:
In <Hz********@cwi .nl> "Dik T. Winter" <Di********@cwi .nl> writes:

....
You are still missing the point. These commands do not generate spaces,
so there is no conversion.


Reopen the file, with the same vi settings and use the shift right
command, then save the file and check that the hand input spaces are
gone:

fangorn:~/tmp 162> od -b foo
0000000 011 141 154 160 150 141 012
0000007

Where are the spaces I have input with my hand?


Nowhere. With your command you asked vi to recalculate the indentation.
How is vi to know how you want the reindentation to be done? Should it
have added four spaces in front of each line? if so, what about lines
with initial tabs, the tabs should be expanded to spaces?
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Nov 14 '05 #164
On 9 Jun 2004 15:34:18 GMT,
Dan Pop <Da*****@cern.c h> wrote:


fangorn:~/tmp 162> od -b foo
0000000 011 141 154 160 150 141 012
0000007

Where are the spaces I have input with my hand?

The behaviour is consistent between vim on Linux and vi on Solaris, BTW.

And anyone who don't like this behaviour could start using vim and set
the :expandtab option. For example by adding the folloing at the beginning
or the end of your C source file:

/* vim :set cindent shiftwidth=4 expandtab: */

If you don't like cindent just ommit it.

Villy
Nov 14 '05 #165
In <ln************ @nuthaus.mib.or g> Keith Thompson <ks***@mib.or g> writes:
Da*****@cern.c h (Dan Pop) writes:
[...]
It certainly is, when you expect *consistent* behaviour from vi on all
platforms. The *last* thing I want to do when using vi is remembering on
which platform I am and what is the right solution for my problem.

It is already bad enough that Solaris comes with an ancient, BSD-style
vi that doesn't recognise the cursor keys in input mode...


You might consider downloading one of the free vi clones (vim, nvi,
whatever) and building it on Solaris -- though that might not be
practical if you jump around to various machines.


I jump around hundreds of machines, as I'm working in a computer center,
hence my strong preference for building a consistent environment out of
the "standard" components available. I'm perfectly capable of using vi
without cursor keys at all (except for hjkl in command mode) and this is
what I do when having to do significant work on Solaris (regardless of
what system I happen to be at the moment).

At some point, I had to deal with 8 different Unix flavours and the
worst incompatibility for interactive sessions was the ps command
(ps aux vs ps -ef), so I've put it behind a wrapper script. A lot
of fun making software work everywhere, since this was in the days
before the great Unix unification (SUS1) and the original POSIX was
a big failure (it ignored far too many things, especially BSDisms).

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #166
In <Hz********@cwi .nl> "Dik T. Winter" <Di********@cwi .nl> writes:
In article <ca**********@s unnews.cern.ch> Da*****@cern.ch (Dan Pop) writes:
In <Hz********@cwi .nl> "Dik T. Winter" <Di********@cwi .nl> writes:...
You are still missing the point. These commands do not generate spaces,
so there is no conversion.


Reopen the file, with the same vi settings and use the shift right
command, then save the file and check that the hand input spaces are
gone:

fangorn:~/tmp 162> od -b foo
0000000 011 141 154 160 150 141 012
0000007

Where are the spaces I have input with my hand?


Nowhere. With your command you asked vi to recalculate the indentation.


I have merely asked everything to be moved 4 positions to the right.
How is vi to know how you want the reindentation to be done?
According to the sw setting.
Should it have added four spaces in front of each line?
For best results, in front of each non-white space character on each of
the lines affected by the shift command. No recalculation needed at all!
ONLY left shifts need recalculation, in the presence of tabs. And this
recalculation should never replace spaces by tabs.
if so, what about lines
with initial tabs, the tabs should be expanded to spaces?


According to the above, tabs become an issue only for left shifts.

Depending on the exact nature of the shift, one tab may have to be
converted to spaces and some of the spaces removed. Unless you know a
better way of implementing left shifts on lines starting with tabs.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #167
In <Hz********@cwi .nl> "Dik T. Winter" <Di********@cwi .nl> writes:
In article <ca**********@s unnews.cern.ch> Da*****@cern.ch (Dan Pop) writes:
In <sl************ ****@ID-227112.user.uni-berlin.de> Sam Dennis <sa*@malfunctio n.screaming.net > writes:...
Not here; I have 'expandtab' set by default. While there may not be a
universal solution for all vi clones, that's no reason to ignore those
presented by the individual editors you use.


It certainly is, when you expect *consistent* behaviour from vi on all
platforms. The *last* thing I want to do when using vi is remembering on
which platform I am and what is the right solution for my problem.


Wrong. You expect consistent behaviour from vi and vim, two completely
different programs. That vim is called vi on some platforms is irrelevant.


I don't expect it, I'm doing my best to configure vi in such a way that it
becomes consistent across platforms. I couldn't care less about the real
name of the program I get when I invoke vi (at some time in the past,
elvis and later nvi were the "vi" of the Linux distributions I was using).
It is already bad enough that Solaris comes with an ancient, BSD-style
vi that doesn't recognise the cursor keys in input mode...


Why, exactly, is this bad? And to be sure, I know of only one vi, the old
BSD-style one.


That's due to your ignorance. There are also SystemV vi, POSIX vi, SUSx
vi.

From the Solaris man page:

The standard Solaris version of vi will be replaced by the
POSIX.2-conforming version (see standards(5)) in the future.
Others are clones under different names.
OK, what are the "real" names of "the standard Solaris version of vi",
SystemV vi, POSIX vi and SUSx vi?
This is similar
to complaining that cc under Solaris does not do exactly the same as cc
under Linux.


It is similar to complaining that a system supposend to follow a standard
doesn't follow it completely. See the above quote from the vi man page
on Solaris.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #168
Um, guys, there is a comp.editors newsgroup. I suspect everyone here
either knows how vi handles tabs, or doesn't care.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #169
In <ln************ @nuthaus.mib.or g> Keith Thompson <ks***@mib.or g> writes:
Um, guys, there is a comp.editors newsgroup. I suspect everyone here
either knows how vi handles tabs, or doesn't care.


In which case, they killfiled this thread, already tagged as off topic,
long ago.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #170

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

Similar topics

699
34429
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it could be possible to add Pythonistic syntax to Lisp or Scheme, while keeping all of the...
22
3444
by: Tuang | last post by:
I'm checking out Python as a candidate for replacing Perl as my "Swiss Army knife" tool. The longer I can remember the syntax for performing a task, the more likely I am to use it on the spot if the need arises. If I have to go off and look it up, as I increasingly have to do with Perl's ever hairier syntax, I'm more likely to just skip it, making me even less likely to remember the syntax the next time. So I hear that Python is easier...
14
2322
by: Sandy Norton | last post by:
If we are going to be stuck with @decorators for 2.4, then how about using blocks and indentation to elminate repetition and increase readability: Example 1 --------- class Klass: def __init__(self, name):
16
2619
by: George Sakkis | last post by:
I'm sure there must have been a past thread about this topic but I don't know how to find it: How about extending the "for <X> in" syntax so that X can include default arguments ? This would be very useful for list/generator comprehensions, for example being able to write something like: instead of the less elegant explicit loop version that has to check for the length of each sequence. What do you think ? George
23
2548
by: Carter Smith | last post by:
http://www.icarusindie.com/Literature/ebooks/ Rather than advocating wasting money on expensive books for beginners, here's my collection of ebooks that have been made freely available on-line by their authors. There are lots of them out there but this selection cuts out the junk. If you know of any other good books that are freely available please post a link to them here and I'll consider adding them to the site.
19
2985
by: Nicolas Fleury | last post by:
Hi everyone, I would to know what do you think of this PEP. Any comment welcomed (even about English mistakes). PEP: XXX Title: Specialization Syntax Version: $Revision: 1.10 $ Last-Modified: $Date: 2003/09/22 04:51:49 $ Author: Nicolas Fleury <nidoizo at gmail.com> Status: Draft Type: Standards Track
4
3792
by: Jeremy Yallop | last post by:
Looking over some code I came across a line like this if isalnum((unsigned char)c) { which was accepted by the compiler without complaint. Should the compiler have issued a diagnostic in this case? (I think it's not required to, but I'd like confirmation). Jeremy.
4
7635
by: Bob hotmail.com> | last post by:
Everyone I have been spending weeks looking on the web for a good tutorial on how to use regular expressions and other methods to satisfy my craving for learning how to do FAST c-style syntax highlighting in C# but I have yet to find anything useful I know there are people at MS that know this stuff like the front of their hand and I know there are many people out on the web that are proficient in doing this as well but it seems nobody...
3
16266
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very strange error. In your experience, where I should looking to find the real error? Surely the sintax of glut is correct... gcc.exe -c glut_bitmap.c -o glut_bitmap.o -I"C:/Dev-Cpp/include" -I"../../include" -D__GNUWIN32__ -W -DWIN32 -DNDEBUG...
0
9969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9810
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
11203
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...
1
10896
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10443
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7999
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...
1
4650
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4251
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3257
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.