Method references (Implementation Issue)
Each method reference is transformed to a closure:
// Math#sqrt(double) will be transformed to { double d => Math.sqrt(d) } { double => double } sqrt = Math#sqrt(double);
Instance method references are transformed in a similar way.
Circle c = new Circle(); { => void } p = c#draw(); // the same as { => c.draw(); }
{ Circle => void } p = Circle#draw(); // { Circle c => c.draw(); }
Let us have a look at another example. We declare class Box
:
public class Box<T> { T v; public Box(T v) { this.v = v; } public T getValue() { return v; } public void print() { System.out.println("Box: " + v); } }
and refer to the print
method:
// Box#print() will be transformed to { Box<Integer> box => box.print(); } { Box<Integer> => void } p = Box#print();
Reference to a generic method will be replaced by a closure as follows:
public class Generic { public static <T> Box<T> copy(Box<T> b) { return new Box<T>(b.getValue()); } }
// Generic#copy(Box<Integer>) will be transformed to // { Box<Integer> box => Generic.copy(box) } { Box<Integer> => Box<Integer> } boxCopy = Generic#copy(Box<Integer>);
I do not want closures in Java because they are not simple.
This argument is wrong. We should always weigh all pros and cons. Closures are not simple. But is software development in Java simple? What should I know to be capable to develop software in Java? Knowledge of the Java programming language is clearly not enough. One should also know some Java technologies and frameworks. And are they simple? Are JPA, EJB, JAX-WS, Hibernate, or Spring (to name a few) simple? Apparently no, so it does not make sense to reject closures just for this reason.
10 comments:
I would even want to go further than your statement about closures
IMHO there is this difference between
simple versus complex
easy versus difficult
By the way: things that are complex may appear to be difficult
in the context of programming
simple/complex is mainly a syntactic thing
(syntax is about the form of programming language constructs)
easy/difficult is mainly a semantic thing
(semantics is about the meaning of programming language constructs)
q1: are closures complex?
a1: they are simpler that all other Java syntax that has the same semantics
q2: are closures difficult?
a2: well, that depends! I do not want to sound offensive to those who find them difficult, but the answer to this question depends on the capability of us, human beings, to understand a certain concept. Closures are certainly not making the concept more difficult than needed (because of (a1))
Go on doing this tutorial thing, Zdenek!
Luc
Great stuff, thanks a lot!
Hey, I don't know a better place to ask, is there a place where people put their closure powered code? Is there a place where I can put mine?
Well now there is. I'd be glad if you'd pass by and leave comments.
Hi felix,
sure, you can post a closure code here. Another place is perhaps Neal Gafter's blog.
Klik Aja Di Bawah Ini
Pemesanan: 087733776655
http://obatkuat-57.com/
Jual Obat Pembesar Penis Vigrx Plus
Alat Bantu Sex Pria Dan Wanita
Rajanya Obat Kuat Sex
Obat Perangsang Wanita, Obat Gairah Wanita
Obat Pembesar Payudara Monyok, Payudara Kencang
Alat Pembesar Payudara Montok
Alat Pembesar Penis
Alat Sex Pria Boneka Moderen
Obat Pengental Sperma
Minyak Pembesar Penis, Obat Pemanjang Penis
Obat Hernia Paling Ampuh
Obat Pelangsing Badan, Melangsingkan Tubuh
Obat Perapet Vagina
Obat Peninggi Badan, Meninggikan Bada
Obat Pembesar Pantat, Pembesar Bokong
Obat Pemerah Bibir, Pemerah Puting
Obat Pemutih Wajah Alami Tensung Cream
Obat Penggemuk Badan
Obat Penghilang Tatto Permanen Herbal Alami
Kondom Antik Pria
Rajanya Obat Kuat Pria
Alat Bantu Sex Wanita Antik
Alat Bantu Sex Pria
Obat Kuat Herbal
Vimax Obat Pembesar Alat Vital
Cara Memutihkan Selangkangan dan Ketiak
Obat Pelangsing Badan Fatloss Jimpness Beauty
Selaput Dara Perawan Buatan
OBAT KUAT RANJANG. COM
Selamat datang di toko online kami,semoga kehadiran kami bisa membantu menyelesaikan masalah rumah tangga anda
Info pemesanan
call : 082133991881
BBm : 323fac0b
KAMI MENJUAL PRODUK -PRODUK DI BAWAH INI
VIMAX CANADA PEMBESAR PENIS
LINTAH PAPUA PEMBESAR PENIS
OBAT KUAT SEK
ALAT-ALAT SEX
PENIS TEMPEL ELEKTRIK
SEX TOYS PRIA DAN WANITA
PENIS MUTIARA GETAR GOYANG MAJU MUNDUR
VAGINA SILIKON MANUAL
VAGINA SENTER 7 SPEED
PENIS NAGA
ELEKTRIK
PERANGSANG WANITA CAIR
PENINGGI BANDAN
KONDOM DURI SILIKON
PEMBESAR PENIS
GALERI KOSMETIK
CELANA HERNIA
CONTAK KAMI :
Hub: 082133991881
Pin bb: 323fac0b
SITUS BOKEP ARTIS
TANTE TANTE KESEPIAN
VIDEO TANTE BUGIL
Thank you for sharing in this article
I can learn a lot and could also be a reference
I hope to read the next your article updates
Vimax Asli
Ciri-ciri Vimax Asli Canada
Vimax Original
Obat Pembesar Penis Herbal
Agen Vimax Original
Vimax
Vimax Asli Canada
Vimax Asli Canada Di Medan
Vimax Original
Vimax Asli Canada Izon
Vimax Obat Pembesar Penis
Vimax Asli
Agen Vimax Original
Obat Pembesar Penis Herbal
Ciri Vimax Asli Canada
Ciri Vimax Asli Canada
Vagina Getar Goyang Alat Bantu Sex Pria
Vimax
Obat Pembesar Penis NeoSize
Alat Pembesar Penis Terbaru Pro Extender
Celana Pembesar Penis Celana Dalam Vakoou
Vakum Pembesar Penis
Vigrx Plus Obat Pembesar Penis
KLG Pill Pembesar Penis Terbaik
Obat Perangsang Wanita Terbaik Blue Wizard Cair
Obat Perangsang Permen Cinta sex Love
Potenzol Obat Perangsang Wanita Terbaik
Obat Kuat Levitra
Viagra USA Asli Obat Sex
Cialis Obat Sex Pria Dewasa
Vakum Pembesar Payudara Permanen
Selaput Dara Buatan
Penis Getar Goyang Mutiara Alat Bantu Sex
Very much useful article. Kindly keep blogging
Java Training in Chennai
Java Online Training India
Thank you for sharing your article. Great efforts put it to find the list of articles which is very useful to know, Definitely will share the same to other forums.
data science course in chennai quora | data science course fees in chennai | data science course in chennai velachery | data science course in chennai omr
Post a Comment