t : : M u r m u r H a s h 3 Murmurhash3 hashing for Perl 6 Uses native call! A l g o r i t h m : : B l o o m F i l t e r A bloom lter implementation with murmurhash3 hashing
programming primitives, lazy and eager list evaluation, junctions, autothreading and hyperoperators (vector operators) Parallelism, concurrency, and asynchrony including multi-core support De nable grammars for pattern matching and generalized string processing Optional and gradual typing
e s t ; c l a s s M y C l a s s { o u r s u b a d d - a l l ( * @ n u m b e r s ) r e t u r n s I n t { [ + ] @ n u m b e r s ; } } m y I n t $ n u m b e r = 1 ; i s M y C l a s s : : a d d - a l l ( $ n u m b e r , 2 , 3 ) , 6 , ' 1 + 2 + 3 i s 6 ' ; d o n e - t e s t i n g ;
. d l l , . s o Something reusable, and compiled down into platform- speci c machine code. Ref: http://www.ibm.com/support/knowledgecenter/SSAW57_8.0.0/com.ibm.websphere.nd.doc/info/ae/ae/tc
s t d i n t . h > u i n t 3 2 _ t a d d _ u i n t 3 2 ( u i n t 3 2 _ t a , u i n t 3 2 _ t b ) { r e t u r n a + b ; } MyHoge.pm6 u s e v 6 ; u s e N a t i v e C a l l ; u n i t m o d u l e M y H o g e ; o u r s u b a d d ( u i n t 3 2 , u i n t 3 2 ) r e t u r n s u i n t 3 2 i s n a t i v e ( ' . / l i b h o g e . s o ' ) i s s y m b o l ( ' a d d _ u i n t 3 2 ' ) { * }
object le g c c - O 2 - f P I C - c l i b h o g e . c - o l i b h o g e . o Link object into executable le g c c - O 2 - f P I C - s h a r e d l i b h o g e . o - o l i b h o g e . s o
v 6 ; u s e M y H o g e ; u s e T e s t ; i s M y H o g e : : a d d ( 1 , 2 ) , 3 , ' 1 + 2 i s 3 ' ; d o n e - t e s t i n g ; Run test: p r o v e - e " p e r l 6 - I . " t e s t . p 6 t e s t . p 6 . . o k A l l t e s t s s u c c e s s f u l . F i l e s = 1 , T e s t s = 1 , 0 w a l l c l o c k s e c s ( 0 . 0 1 u s r 0 . 0 1 s y s + 0 . 4 6 c u s r 0 . 0 5 R e s u l t : P A S S
H O N Y : t e s t c l e a n C F L A G S = - f P I C - O 2 a l l : l i b h o g e . s o l i b h o g e . s o : l i b h o g e . o $ ( C C ) $ ( C F L A G S ) - s h a r e d l i b h o g e . o - o $ @ l i b h o g e . o : l i b h o g e . c $ ( C C ) $ ( C F L A G S ) - c l i b h o g e . c - o $ @ t e s t : l i b h o g e . s o p r o v e - e " p e r l 6 - I . " t e s t . p 6 c l e a n : - r m l i b h o g e . o l i b h o g e . s o and do: m a k e & & m a k e t e s t & & m a k e c l e a n
t y p e ] for C array. i n t 3 2 _ t a d d _ a l l ( i n t 3 2 _ t n u m b e r s [ ] , u i n t 3 2 _ t s i z e ) { u i n t 3 2 _ t i ; i n t 3 2 _ t s u m = 0 ; f o r ( i = 0 ; i < s i z e ; i + + ) { s u m + = n u m b e r s [ i ] ; } r e t u r n s u m ; } s u b a d d - a l l ( C A r r a y [ i n t 3 2 ] , u i n t 3 2 ) r e t u r n s i n t 3 2 i s n a t i v e ( ' . / l i b h o g e . s o ' ) i s s y m b o l ( ' a d d _ a l l ' ) { * } m y @ n u m b e r s : = C A r r a y [ u i n t 3 2 ] . n e w ; @ n u m b e r s [ 0 ] = 1 ; @ n u m b e r s [ 1 ] = 2 ; @ n u m b e r s [ 3 ] = 3 ; i s a d d - a l l ( @ n u m b e r s , @ n u m b e r s . e l e m s ) , 6 ;
r u c t p e r s o n { u i n t 3 2 _ t i d ; c h a r * n a m e ; } P e r s o n ; P e r s o n * P e r s o n _ c r e a t e ( u i n t 3 2 _ t i d , c h a r * n a m e ) { P e r s o n * p = m a l l o c ( s i z e o f ( P e r s o n ) ) ; p - > i d = i d ; p - > n a m e = n a m e ; r e t u r n p ; }
struct object. c l a s s P e r s o n r e p r ( ' C S t r u c t ' ) { h a s u i n t 3 2 $ . i d ; h a s S t r $ . n a m e ; s u b c r e a t e ( u i n t 3 2 , S t r ) r e t u r n P e r s o n i s n a t i v e ( . / l i b h o g e . s o ' ) i s s y m b o l ( ' P e r s o n _ c r e a t e ' ) { * } m e t h o d n e w ( I n t : $ i d , S t r : $ n a m e ) { c r e a t e ( $ i d , $ n a m e ) } } m y P e r s o n $ p = P e r s o n . n e w ( i d = > 1 2 3 , n a m e = > ' h o g e ' ) ; i s $ p . i d , 1 2 3 ; i s $ p . n a m e , ' h o g e ' ;
to a struct object goes away, GC will free the memory. Except when struct-based type is used. Object members are not in "containers" Assigning a value to a member will not work t y p e d e f s t r u c t l i n e { P o i n t * p 1 , P o i n t * p 2 } L i n e ; / / M u s t f r e e b y y o u r s e $ ! i d = 1 2 3 4 ; # C a n n o t a s s i g n t o a n i m m u t a b l e v a l u e
@ a r r a y : = C A r r a y [ u i n t 3 2 ] . n e w ; or m y $ a r r a y = C A r r a y [ u i n t 3 2 ] . n e w ; and not m y @ a r r a y = C A r r a y [ u i n t 3 2 ] . n e w ; Ref https://docs.perl6.org/language/nativecall#Arrays
t 3 2 works for scalar... # i n c l u d e < s t d i n t . h > u i n t 3 2 _ t b i g _ u i n t 3 2 ( ) { r e t u r n s U I N T 3 2 _ M A X ; } u s e v 6 ; u s e N a t i v e C a l l ; s u b b i g _ u i n t 3 2 ( ) r e t u r n u i n t 3 2 i s n a t i v e ( ' . . . ' ) { * } s a y b i g _ u i n t 3 2 ( ) ; # 4 2 9 4 9 6 7 2 9 5
g _ u i n t 3 2 _ a r r a y ( u i n t 3 2 _ t n u m b e r s [ ] ) { n u m b e r s [ 0 ] = U I N T 3 2 _ M A X ; } u s e N a t i v e C a l l ; s u b b i g _ u i n t 3 2 _ a r r a y ( C A r r a y [ u i n t 3 2 ] ) i s n a t i v e ( ' . . . ' ) { * } m y @ n u m : = C A r r a y [ u i n t 3 2 ] . n e w ; @ n u m [ 0 ] = 0 ; b i g _ u i n t 3 2 _ a r r a y ( @ n u m ) ; s a y @ n u m [ 0 ] ; # - 1
: : M u r m u r H a s h 3 ... c o n s t a n t U I N T 3 2 _ M A X = 4 2 9 4 9 6 7 2 9 5 ; o u r s u b f i x - s i g n - b i t ( I n t : D $ v - - > I n t ) { $ v . s i g n = = - 1 ? ? $ v + 1 + U I N T 3 2 _ M A X ! ! $ v ; }
other languages are taking its position. But C still brings us a good opportunity to learn. How programs are compiled, linked, and ran How memory is allocated, used, and freed How to resolve realworld problems with primitive functions and libraries
and iOS SDKs In marketing research eld Our Environment: Have iOS app deployed to TW, SG, and ID Global teams in JP, US, CN, KR, PH, SG, US, and GB English communication opportunities Unlimited free beer o ered on every Wednesdays If interested, contact me anytime.