与不区分大小写的语言相比,区分大小写的语言有什么优势? [英] What's the advantage of case sensitive languages over case insensitive ones?

查看:74
本文介绍了与不区分大小写的语言相比,区分大小写的语言有什么优势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在Delphi中做过许多项目,这些项目使用不区分大小写的语言Pascal,并且我想知道区分大小写的语言的优点是什么。

Jason 争论不区分大小写会带来很多歧义。我不同意如果您意识到该语言不区分大小写,则知道 WHILE while 的含义相同,即使您从未写前者。变量和函数相同;骆驼的外壳很好,但是首字母还是大写吗?那么以下划线开头的函数呢?在不区分大小写的语言中,没问题: _fooBar 的效果与 _FooBar 一样好。那么Jason指的是什么歧义?是的,您可以用不同的方式编写变量,但是含义是明确的! FooBar == foobar

I have been doing a number of projects in Delp which uses the case insensitive language Pascal, and I was wondering what the advantage of case sensitive languages is.
Jason argues that "Case insensitivity introduces much ambiguity". I don't agree. If you realize that the language is case insensitive you know that WHILE means the same thing as while, even if you never write the former. Same for variables and functions; camel casing is nice, but was the first letter also a capital or not? And what about functions whose name starts with an underscore? In case insensitive languages no problem: _fooBar will do just as nicely as _FooBar. So where's the ambiguity Jason refers to? Yes, you can write a variable in different ways, but the meaning is unambiguous! FooBar == foobar!

在同一线程中德尔南表示资本化是我不得不帮助我叔叔杰克下马..和我不得不帮助我叔叔杰克下马。 。非常聪明 :-)。但这不是对大小写敏感的反对:您是否会因为一个大写错误而使代码陷入困境?同样,在不区分大小写的语言中,如果 Jack 是人,那么 jack 也是人。

In the same thread Delnan says that Capitalization is the difference between "I had to help my uncle Jack off a horse.." and "I had to help my uncle jack off a horse..". Very clever :-). But rather a point against than pro case sensitivity: would you accept that your code goes haywire because of a single capitalization error? Again, in a case insensitive language, if Jack is a person, so is jack.

问题:是否有人在区分大小写的语言中使用此功能,您可以仅通过不同的大小写来定义两个不同的变量或函数?因为那是我所能看到的唯一优势。当然,您会说,我用驼峰式大小写变量名,并用大写形式写常量。但是IMO它们是不兼容的; userName 作为变量是有意义的,但 USERNAME 作为常量则没有意义。

Question: is there anyone who uses this feature in case sensitive languages that you can define two different variables or functions just by different capitalization? Because that's the only advantage I can see in it. Sure, you'll say, I write the variable name with camel casing and the constant all uppercase. But IMO they're incompatible; userName as a variable makes sense, but USERNAME as a constant doesn't.

(我意识到许多程序员都使用区分大小写的语言,所以我准备接受不受欢迎的接待:-))

(I realize that many programmers use case sensitive languages, so I'm prepared for a unwelcome reception :-))

编辑

这个问题的触发源是Lynda.com的 Flash CS3 Professional中的ActionScript 3.0培训视频,其中Todd Perkins花费了一半的时间来强调大写:-)

edit
The trigger for this question was Lynda.com's "ActionScript 3.0 in Flash CS3 Professional" training video, in which Todd Perkins spends half of his time emphasizing the capitalizations :-)

推荐答案

是的,我绝对在C#中一直使用它:

Yes, I absolutely use this all the time in C#:

private readonly string name;
public string Name { get { return name; } }

我倾向于使用区分大小写的语言,并且还没有真正看到它们-除了其他以外,它们大小写一致。

I've tended to use case-sensitive languages, and haven't really seen downsides of them - aside from anything else, they force consistency of casing.

不过,我认为这确实是个人喜好。

It's really a personal preference thing though, I think.

这篇关于与不区分大小写的语言相比,区分大小写的语言有什么优势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆