伪代码 - 形式规则
有没有人提出正式伪代码标准的提案?
作为一个“粗略”的标准来推断理解是否更好?
Has anyone set out a proposal for a formal pseudo code standard?
Is it better to be a 'rough' standard to infer an understanding?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
最好是制定一个粗略的标准;伪代码的目的是人类可读,而不是机器可读,实际编写伪代码的目标是传达算法的更高级别描述,同时不关心(通常)实现的细节。我的观点是,要使其成为伪代码,必须存在一些歧义,并且您的目标应该是清楚地传达您的算法意图。坚持对你的目标受众或语言来说是典型的通用控制结构、声明和概念,你就会明白这一点。如果你开始变得过于正式,那么你就离编写实际代码太近了。
It is better to be a rough standard; the intent of pseudocode is to be human-readable, not machine-readable, and the goal of actually writing pseudocode is to convey a higher-level description of an algorithm while being unconcerned (typically) with the minutiae of the implementation. My opinion is that for it to qualify as pseudocode there has to be some ambiguity, and your goal should be a clear conveyance of your algorithmic intentions. Stick to common control structures, declarations and concepts that are paradigmatic to your target audience or language and you'll get the point across. If you start getting too formal, you're getting too close to writing actual code.
不是答案。
恕我直言,强制采用标准(伪代码语法,如果你愿意的话)会导致人们不太清楚他们想说的内容。
四处浏览,尝试收集一些有关已用约定的知识,并尽力使其清晰。
NOT AN ANSWER.
IMHO forcing a standard (pseudo code syntax, if you will) will cause people to be less clear on what they want to say.
Browse around, try to gather some knowledge about used conventions, and do your best to be clear.
尽管这绝不是正式提案,但有些人认为 Python 是可执行伪代码。
Although this is by no means a formal proposal, Python is considered by some to be Executable Pseudocode.
在我看来,这取决于使用你的程序的人。在算法书籍中,伪代码非常正式,接近数学,但也在几段中进行了描述,因此这是针对科学情况的。
如果我在其他环境中开发,我会更喜欢不那么正式的方式,因为这对大多数人来说更容易理解。比起形式主义,我更喜欢口头语言。如果你想要形式主义,你可以阅读代码。
in my opinion it depends on the people who are using your programs. In books for algorithms the pseudo code is very formal an near to maths, but is also described in a few paragraphs, so this is for scientific situations.
If I develop in others environments I would prefer a not that formal way because that is easier to understand for most people. I prefer spoken words over formalism. If you want formalism you could read the code instead.