-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
for own key in { ... } #32
Comments
hmm good idea - needs a decent keyword ... for key within obj { doSomething(); } ? Love some help .. On Mon, Jun 13, 2011 at 6:02 PM, benekastah <
|
or
Edit: sorry, accidentally closed the issue. |
inside ? On Mon, Jun 13, 2011 at 6:23 PM, benekastah <
|
hmmm... I feel like I'm a little bit stuck on own. I think it's an intuitive word because it is in the native JavaScript method hasOwnProperty. What about:
making forown a new keyword? |
How about : for key in obj { ^_^ Tapped on my fone On 13 Jun 2011, at 18:02, benekastah < for (var key in obj) { |
Why do you need this feature so ? What's your use case. ? Tapped on my fone On 13 Jun 2011, at 19:36, benekastah
|
Fair enough, lol. Well, I will try to put something together to make this work tonight. I'll pick a keyword for you to veto :) Edit: just saw your comment above. I always loop that way by default, because otherwise I am looping through all the parent prototypes of the object. When I'm looping through an object, most often I only care about the direct members of that object (although this isn't always the case). It's an optimization, but it's also a security measure, to make sure that I only modify what I'm expecting to modify. |
for x from y { .. } ? |
while we're on the subject, it would be nice to be able to range between two variables. i.e. sugar for : could do for i=1..3 { } or for i of [a..b] |
I really like About the ranges, what if a range simply resolved to an array?
Then looping would be built in:
Additionally, one could use the |
yeah :) how about: [a..b] goes to __array(a,b) function __array(x,y) { var a = []; for(var i=x; i |
I like it (I will infer the rest of that function :). Should we distinguish between inclusive and exclusive ranges?
|
[1..5] // => [1,2, 3, 4, 5] On Tue, Jun 14, 2011 at 5:48 PM, benekastah <
|
I am authoring a language like Kaffeine. My thoughts are to steal from LiveScript in this instance: http://livescript.net/ The keywords used there are much less ambiguous (do I use one dot? do I use two? let me check the manual...)
Also I would like to see hasOwnProperty be the default looping construct. If you want ancestor keys then add something like this:
|
Awesome. Like the keywords. What's your philosophy for the language ? On Friday, January 4, 2013, Chris M. Welsh wrote:
|
Are there plans to develop a method to easily generate a javascript for...in loop like:
I think a variant of CoffeeScript's solution would be elegant:
For me, this is the only really crucial thing I find missing from kaffeine. I will probably still end up using (and contributing) to it even with this missing because of how awesome async programming will be with this tool.
The text was updated successfully, but these errors were encountered: