473,786 Members | 2,404 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 7092
"Dik T. Winter" <Di********@cwi .nl> writes:
In article <c9**********@s unnews.cern.ch> Da*****@cern.ch (Dan Pop) writes:
> >On Thu, 3 Jun 2004, Dan Pop wrote:
> >[re: hard tabs]
> >> A typical example is vi, which "optimises" the storage of the
> >> saved text by replacing multiple spaces by HTs according to the ts
> >> variable setting. Since I have found no portable way of disabling
> >> this feature, I'm setting ts to 100 in my .exrc.

...
> The latter. vi's response to "set ts=0":
>
> Argument must be positive: ts=0


Which 'vi' is that? None of the two apply to 'vi' on Solaris, so I
expect it is something that some poor soul thought useful and implented
on some particular system.


Solaris vi (":version" prints "Version SVR4.0, Solaris 2.5.0") allows
"set ts=0", but it silently sets tabstop to 8.

vi (at least in the versions I've used) doesn't convert space
characters to tabs, but it does use tabs whenever possible for
indentation. With the default setting of "ts=8", spaces inserted by
hitting the space bar in insert mode remain as space characters, but
any leading whitespace created by control-T or adjusted by the '[' and
']' commands is converted to tabs. A 12-space indentation, for
example, becomes a tab followed by 4 spaces.

Once upon a time I actually liked this behavior. I found that I could
convert leading indentation to tabs by shifting the entire buffer to
the right and then back to the left. Now that I prefer to use just
spaces, I filter the buffer through the Unix "expand" command. (vim
might handle this better but I like nvi.)

--
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 #151
In article <ln************ @nuthaus.mib.or g> Keith Thompson <ks***@mib.or g> writes:
"Dik T. Winter" <Di********@cwi .nl> writes: ....
Which 'vi' is that? None of the two apply to 'vi' on Solaris, so I
expect it is something that some poor soul thought useful and implented
on some particular system.

.... vi (at least in the versions I've used) doesn't convert space
characters to tabs, but it does use tabs whenever possible for
indentation. With the default setting of "ts=8", spaces inserted by
hitting the space bar in insert mode remain as space characters, but
any leading whitespace created by control-T or adjusted by the '[' and
']' commands is converted to tabs. A 12-space indentation, for
example, becomes a tab followed by 4 spaces.


Yup, it is done when using auto-indent (which I never use), both with vi
and vim. In that case setting ts to some huge value will disable it and
use spaces only (but actual tabs in the file will look, eh, ugly). And,
indeed, there is no option when using auto-indent to disallow spaces
while ts has a sensible value.
--
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 #152
In article <c9**********@s unnews.cern.ch> Da*****@cern.ch (Dan Pop) writes:
In <Hy********@cwi .nl> "Dik T. Winter" <Di********@cwi .nl> writes:

....
Well, the implementation that came with the version of Linux (Fedora) I am
using does indeed disallow ts=0. But it does *not* optimise storage by
replacing multiple spaces by HTs. Just checked vim on Suse, also did not
do that. Also vim on my home machine (a Mac running MacOS) does not perform
that optimisation. Assuming that all vim's are created equal is wrong.
(But I suspect that you are using some obscure option that forces this
feature.)


You're still not getting it. If no vi ever replaced my spaces by tabs
I wouldn't have searched a solution to the problem in the first place.
I don't remember which vi flavour did that, but I do remember that setting
ts to 0 didn't work and, as I've already explained, even if it worked,
it wouldn't have been a satisfactory solution.


You still do not get it. First you said that 'vi' does it (without
qualification), next you say that it is actually 'vim' (again without
qualification), now it appears that it is some obscure version of 'vim',
modified from the original by someone to get the effect you described.
But you expect a general solution:
Since I have found no portable way of disabling
this feature,

while the problem only exists in some obscure version. If somebody
gives you a piece of software that he has broken in some way, you should
not expect a 'portable' solution to unbreak it. You will not find a
portable solution because the bug is in general not present.
--
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 #153
In <Hy********@cwi .nl> "Dik T. Winter" <Di********@cwi .nl> writes:
In article <ln************ @nuthaus.mib.or g> Keith Thompson <ks***@mib.or g> writes:
"Dik T. Winter" <Di********@cwi .nl> writes:

...
Which 'vi' is that? None of the two apply to 'vi' on Solaris, so I
expect it is something that some poor soul thought useful and implented
on some particular system.

...
vi (at least in the versions I've used) doesn't convert space
characters to tabs, but it does use tabs whenever possible for
indentation. With the default setting of "ts=8", spaces inserted by
hitting the space bar in insert mode remain as space characters, but
any leading whitespace created by control-T or adjusted by the '[' and
']' commands is converted to tabs. A 12-space indentation, for
example, becomes a tab followed by 4 spaces.


Yup, it is done when using auto-indent (which I never use), both with vi
and vim. In that case setting ts to some huge value will disable it and
use spaces only (but actual tabs in the file will look, eh, ugly). And,
indeed, there is no option when using auto-indent to disallow spaces
while ts has a sensible value.


So, who was the one who wasn't getting it?

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #154
In article <ca***********@ sunnews.cern.ch > Da*****@cern.ch (Dan Pop) writes:
In <Hy********@cwi .nl> "Dik T. Winter" <Di********@cwi .nl> writes:
In article <ln************ @nuthaus.mib.or g> Keith Thompson <ks***@mib.or g> writes:
"Dik T. Winter" <Di********@cwi .nl> writes:

...
> Which 'vi' is that? None of the two apply to 'vi' on Solaris, so I
> expect it is something that some poor soul thought useful and implented
> on some particular system.

...
vi (at least in the versions I've used) doesn't convert space
characters to tabs, but it does use tabs whenever possible for
indentation. With the default setting of "ts=8", spaces inserted by
hitting the space bar in insert mode remain as space characters, but
any leading whitespace created by control-T or adjusted by the '[' and
']' commands is converted to tabs. A 12-space indentation, for
example, becomes a tab followed by 4 spaces.


Yup, it is done when using auto-indent (which I never use), both with vi
and vim. In that case setting ts to some huge value will disable it and
use spaces only (but actual tabs in the file will look, eh, ugly). And,
indeed, there is no option when using auto-indent to disallow spaces
while ts has a sensible value.


So, who was the one who wasn't getting it?


In that case there is a completely standard way to avoid it. Set
auto-indent off. But note that in this case vi is *not* converting
spaces to tabs. When due to an auto-indent it goes to a specific
places it does this with a mixture of tabs and spaces. So there is
no conversion at all. Got it? Note that even if auto-indent is on,
when you enter 12 spaces no conversion takes place... Your complaint
was:
A typical example is vi, which "optimises" the storage of the
saved text by replacing multiple spaces by HTs according to the ts
variable setting. Since I have found no portable way of disabling
this feature, I'm setting ts to 100 in my .exrc.

None of this happens, even when auto-indent is on.
--
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 #155
In <Hy********@cwi .nl> "Dik T. Winter" <Di********@cwi .nl> writes:
In article <ca***********@ sunnews.cern.ch > Da*****@cern.ch (Dan Pop) writes:
In <Hy********@cwi .nl> "Dik T. Winter" <Di********@cwi .nl> writes:
In article <ln************ @nuthaus.mib.or g> Keith Thompson <ks***@mib.or g> writes:
> "Dik T. Winter" <Di********@cwi .nl> writes:
...
> > Which 'vi' is that? None of the two apply to 'vi' on Solaris, so I
> > expect it is something that some poor soul thought useful and implented
> > on some particular system.
...
> vi (at least in the versions I've used) doesn't convert space
> characters to tabs, but it does use tabs whenever possible for
> indentation. With the default setting of "ts=8", spaces inserted by
> hitting the space bar in insert mode remain as space characters, but
> any leading whitespace created by control-T or adjusted by the '[' and
> ']' commands is converted to tabs. A 12-space indentation, for
> example, becomes a tab followed by 4 spaces.

Yup, it is done when using auto-indent (which I never use), both with vi
and vim. In that case setting ts to some huge value will disable it and
use spaces only (but actual tabs in the file will look, eh, ugly). And,
indeed, there is no option when using auto-indent to disallow spaces
while ts has a sensible value.


So, who was the one who wasn't getting it?


In that case there is a completely standard way to avoid it. Set
auto-indent off. But note that in this case vi is *not* converting
spaces to tabs. When due to an auto-indent it goes to a specific
places it does this with a mixture of tabs and spaces. So there is
no conversion at all. Got it? Note that even if auto-indent is on,
when you enter 12 spaces no conversion takes place...


Still badly missing the point. I seldom use auto-indent, but I use
very often other indentation commands, like CTRL-T and shifts, whose
operation is controlled by the setting of sw and, therefore, has nothing
to do with ts. Yet, vi is using the ts setting to convert the spaces
generated by these commands into HTs. Hence my solution to set ts to a
ludicrously large value in my .exrc. There is nothing preventing me
from resetting it to 8 (which I can achieve with a single key press)
when I detect HTs in other people's texts (they're glaringly obvious
when ts is set to 100 ;-)

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #156
In article <ca**********@s unnews.cern.ch> Da*****@cern.ch (Dan Pop) writes:
In <Hy********@cwi .nl> "Dik T. Winter" <Di********@cwi .nl> writes:

....
In that case there is a completely standard way to avoid it. Set
auto-indent off. But note that in this case vi is *not* converting
spaces to tabs. When due to an auto-indent it goes to a specific
places it does this with a mixture of tabs and spaces. So there is
no conversion at all. Got it? Note that even if auto-indent is on,
when you enter 12 spaces no conversion takes place...


Still badly missing the point. I seldom use auto-indent, but I use
very often other indentation commands, like CTRL-T and shifts, whose
operation is controlled by the setting of sw and, therefore, has nothing
to do with ts. Yet, vi is using the ts setting to convert the spaces
generated by these commands into HTs.


You are still missing the point. These commands do not generate spaces,
so there is no conversion.
--
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 #157
CBFalconer <cb********@yah oo.com> wrote in message news:<40******* ********@yahoo. com>...
Dan Pop wrote:
"Arthur J. O'Dwyer" <aj*@nospam.and rew.cmu.edu> writes:
On Thu, 3 Jun 2004, Dan Pop wrote:
[re: hard tabs] A typical example is vi, which "optimises" the storage of the
saved text by replacing multiple spaces by HTs according to
the ts variable setting. Since I have found no portable way
of disabling this feature, I'm setting ts to 100 in my .exrc.

I'm sure you've thought of this, but what happens if you set
ts to 0? I would expect either that it would disable the
"feature" altogether, or that you'd get an error from vi.


The latter. vi's response to "set ts=0":

Argument must be positive: ts=0


What an ugly mechanism. Does that also apply to VIM? I have
sometimes considered installing VIM just to have my editing habits
portable, but that is too big a penalty to pay.


VIM has various extensions in this area that make it very
flexible and remove these issues. It can be easily set up
so that the tab key works as it would in traditional VI,
but spaces are used instead of tabs to do the indentation.
It can also easily convert tab characters in a file to an
appropriate number of spaces based on a configurable hard
tab width.

If you want a VI-like editor, I recommend VIM highly.
Nov 14 '05 #158
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 <Hy********@cwi .nl> "Dik T. Winter" <Di********@cwi .nl> writes:

...
In that case there is a completely standard way to avoid it. Set
auto-indent off. But note that in this case vi is *not* converting
spaces to tabs. When due to an auto-indent it goes to a specific
places it does this with a mixture of tabs and spaces. So there is
no conversion at all. Got it? Note that even if auto-indent is on,
when you enter 12 spaces no conversion takes place...


Still badly missing the point. I seldom use auto-indent, but I use
very often other indentation commands, like CTRL-T and shifts, whose
operation is controlled by the setting of sw and, therefore, has nothing
to do with ts. Yet, vi is using the ts setting to convert the spaces
generated by these commands into HTs.


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


Bullshit. 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:

fangorn:~/tmp 158> od -b foo
0000000 040 040 040 040 141 154 160 150 141 012
0000012

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?

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

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #159
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.

--
++acr@,ka"
Nov 14 '05 #160

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

Similar topics

699
34241
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
3433
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
2316
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
2610
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
2539
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
2976
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
3785
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
7625
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
16253
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
9647
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
9492
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,...
1
10108
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
9960
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
7510
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
6744
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
5397
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
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3668
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.