TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

PHP to Objective C, where are the parameters?

21 点作者 kentnguyen超过 13 年前

6 条评论

mmariani超过 13 年前
Not a bad intro to ObjC message syntax. Even though the article has few mistakes.<p>Most notably ObjC syntax does not have functions that are called, it has messages that are sent to objects and classes. In the end all messages are "translated" to C function calls to objc_msgSend().<p>Everything makes sense after you read the proper documentation. Which in this case is <a href="http://developer.apple.com/library/mac/documentation/Cocoa/Reference/ObjCRuntimeRef/ObjCRuntimeRef.pdf" rel="nofollow">http://developer.apple.com/library/mac/documentation/Cocoa/R...</a>
评论 #3470765 未加载
评论 #3471205 未加载
roadnottaken超过 13 年前
I was interested in this article when I saw that you<p><i>"... wanted to help out those who began to learn iOS evelopment, especially programmers who are coming from no programming background or web development background"</i><p>but then the first line of your next article is:<p><i>"I assume you are very familiar with declaring functions in [Javascript, PHP, or Ruby], if not, you should not be reading this"</i><p>So... which one is it? A tutorial for non-programmers or programmers familiar with other languages? or a tutorial specifically for people fluent in Javascript/PHP/Ruby?
RandallBrown超过 13 年前
I'm going to have to start referring to this post when I explain why I like objective c. Usually people just give me this crazy stare like I'm some kind of moron.<p>One thing though, if you spell a method name wrong, it will still compile. It's only a warning that "the object may not respond to that selector". Of course if you have warnings as errors turned on, then of course it will error.
评论 #3470763 未加载
评论 #3470710 未加载
dqminh超过 13 年前
python also has this right by introducing named parameters. The same function in python can be written as:<p><pre><code> do_send_mail(recipient="some@email.com", cc="another@email.com", subject="Hello!", body="hi!")</code></pre>
评论 #3470728 未加载
评论 #3470591 未加载
gerggerg超过 13 年前
Totally personal preference. I would rather have a language be concise and the documentation verbose than the other way around or with both verbose.<p>Having it be verbose is great for learning, but after a short while syntax like:<p><pre><code> do_send_email(recipient, cc, subject, body) </code></pre> is much better for quickly reading code. Plus, reading the docs is hugely important. Having to check every now and then is great for getting you back into them.
评论 #3471261 未加载
mattmanser超过 13 年前
<i>I hope you understood the very fundamental reason why Objective-C syntax has to be the way it is.</i><p>It does <i>not</i> need to be like this in a statically typed language. Most statically typed languages don't require you to pass the parameter name. Some have this optionally so you can mix and match or have default values (C# for example <a href="http://msdn.microsoft.com/en-us/library/dd264739.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/dd264739.aspx</a>).<p>If you'd written other statically typed language the Obj-C syntax would probably still be surprising to you.<p>Brilliant design by Apple it is not, it's the nature of statically typed languages. For example your comment:<p><i>Now, which one is the recipient? What is the subject?</i><p>Shows a lack of experience with statically typed languages. IDEs will tell you if you hover over the method with your mouse as well as when you're creating the method (including all the variations).<p>On the other hand it's quite fun to see someone naturally find out some of the reasons why some people prefer statically typed languages.
评论 #3470741 未加载