Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Inline-Methods and Closure-Blocks  (Read 2066 times)
0 Members and 1 Guest are viewing this topic.
Offline zero

Junior Member





« Posted 2007-07-07 14:32:56 »

Yesterday, I had an idea for a new language feature (for Java of course). That is itself nothing special, as I like to think about those, however I believe this really stands out.

The main idea is to inline special methods, which can execute a (closure-)block into the lexical scope where is called.

What sounds really complicated, but in fact it is not. Inspired by the enhanced for-loop syntax, programmers should be familiar with everything after a short introduction. But before I repeat myself over and over, please have a look at the details at my blog or go straight to the Google Document.

- I really believe in this idea, which is why I'd love to get as most feedback as possible.  Smiley
Offline Mr_Light

Senior Member




shiny.


« Reply #1 - Posted 2007-07-07 17:40:38 »

You get down and dirty pretty quick perhaps it's useful to outline the real pain points first.

although i/o is very important, relative to a general purpose language it's kinda niche(ok, that's a bit over the top). I would advice to not leave it to the reader to pull this into(/apply it to) other area's. Adding examples will allow the reader to get a better idea of(/ pin down) your suggestion and you get to test your construct.

//edited - improved some grammar / spelling

More indept, I usually favor words over characters(:%$#@) to indicate contructs unless they are natural (Math) or low profile(seperation char).

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline princec

JGO Kernel


Medals: 282
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #2 - Posted 2007-07-07 20:02:27 »

Yeah, baffles me slightly. Show us a few "problems" and how the new syntax proposes to make it look nicer.

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline zero

Junior Member





« Reply #3 - Posted 2007-07-08 12:53:04 »

Thanks for answering!

@Mr_Light:
Interesting comment,  I never thought it looks IO specific. I believe it has many interesting usages (please see the example below answering to princec)

Btw. I chose the character :' to reuse the for (Object : Iterable it) syntax and '#' because I' not aware of conflicts and it looks like a macro, which is similar in functionality. However these are details, syntax may change.

@princec
I may refer to an example from Neal Gafter's Blog. It's about closures, but benefit is the same: Early exits from loops or recursive functions (in my case recursive inline-methods or those containing loops) without encoding it into return types or whatever.
Offline Mr_Light

Senior Member




shiny.


« Reply #4 - Posted 2007-07-09 07:49:42 »

Thanks for answering!

@Mr_Light:
Interesting comment,  I never thought it looks IO specific. I believe it has many interesting usages (please see the example below answering to princec)

Btw. I chose the character :' to reuse the for (Object : Iterable it) syntax and '#' because I' not aware of conflicts and it looks like a macro, which is similar in functionality. However these are details, syntax may change.

@princec
I may refer to an example from Neal Gafter's Blog. It's about closures, but benefit is the same: Early exits from loops or recursive functions (in my case recursive inline-methods or those containing loops) without encoding it into return types or whatever.
thanks for listening Wink

I can see where you got from and it makes sense. Thinking about it though I feel that in a method your working at a more micro level and a keyword wouldn't hurt. but as you said thats quite missing the point to going on about it at this stage.

hmm I relatively new to the closure discussion, I saw some ppl lock horn's and decided not to get involved till the dust settled. (well ok thats only part I simply didn't have time  Cool) So excuse my naiveness, but if you want to shortcircuit the search you basicly have meta data about the return value.... conditions that yo don't want to tie into your method.  'There isn't any' is rewritten as 'after checking all there is no positive match' -> 'searching yields no positive match'  The implementation of search should not be altered for reuse, preferably else make it receptable to reuse. (aparandly though a hook) 

..I doubt you can see where I'm going so i'll edit it when I'm at work, gotta run to catch the bus now though.

//edit
so ok I'm at work.

an early stop can only be applied to actions that have as a result a collection of things or can 'run' (numbers) If you can 'hint' that your only interested in a restrained result then the jvm can probebly be made smart enough to interpret and optimize it. Specifying the constraint is probably even less verbose then describing the logic to enforce it.

does that make any sense at all?

about the other point; it doesn't look too IO specific but all the examples you gave are only applied to IO, yes Gafter's Blog uses it in another context but also applies a different approach. It's dangerous to refer to other sources or leave it to the reader, because it allows for different views, with subtle differences while everyone has the idea that everyone else has the same idea about it. By the time you have to actually specify it on paper(the specification) all hell breaks lose.

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline princec

JGO Kernel


Medals: 282
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #5 - Posted 2007-07-09 11:29:41 »

If you could get the syntax looking much less obscure I might think it's a good idea but right now it looks like closures simply obfuscate the nice, simple, imperative style that made Java so nice and simple. I know people rave about them but I rather like to be able to understand what something does, and the order it does it in, at a glance, and those bits of code are anything but obvious.

Cas Smiley

Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #6 - Posted 2007-07-17 13:05:04 »

Yesterday, I had an idea for a new language feature (for Java of course). That is itself nothing special, as I like to think about those, however I believe this really stands out.


You never say precisely what the problem is you're trying to solve.
You never say precisely how you're fixing it.

I'm afraid that means you're going to have a very hard time persuading people to your cause.

malloc will be first against the wall when the revolution comes...
Offline keldon85

Senior Member


Medals: 1



« Reply #7 - Posted 2007-07-17 13:21:22 »

You never say precisely what the problem is you're trying to solve.
You never say precisely how you're fixing it.

I'm afraid that means you're going to have a very hard time persuading people to your cause.
It did take me reading it a few times to get what it was about too, you really do go the wrong way about introducing the idea. Your problem is communication, if you can use a more commonly used word in place of a less commonly used one more often you are more likely to get your point across. Look at Sun's text on the enhanced for-loop, simple English, and they also provide examples of the common approach to a particular problem alongside the approach with the new language feature.

You must also think about readability.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (38 views)
2014-04-15 18:08:23

BurntPizza (34 views)
2014-04-15 03:46:01

UprightPath (50 views)
2014-04-14 17:39:50

UprightPath (32 views)
2014-04-14 17:35:47

Porlus (49 views)
2014-04-14 15:48:38

tom_mai78101 (71 views)
2014-04-10 04:04:31

BurntPizza (130 views)
2014-04-08 23:06:04

tom_mai78101 (230 views)
2014-04-05 13:34:39

trollwarrior1 (193 views)
2014-04-04 12:06:45

CJLetsGame (200 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!