-
Notifications
You must be signed in to change notification settings - Fork 0
/
CrazyP6.txt
332 lines (265 loc) · 13.3 KB
/
CrazyP6.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
13/10/2009
[18:40] < shinobi-cl> how should i define something like tr/STRING/es so that
translates the string
[18:40] < shinobi-cl> i mean, define tr// like a new operator...
[18:40] <@moritz_> the perl6ish way would look like Q:trans<es> { STRING }
[18:41] <@PerlJam> shinobi-cl: sub tr ($str,$lang) { ... } # :-)
[18:41] <@moritz_> and you'd define it with macros, which are NYI
[18:41] <@moritz_> (Not Yet Implemented)
[18:41] <@pmichaud> it would still help to know what those macros might look
like, though :)
[18:41] <@moritz_> aye
[18:41] <@pmichaud> an example would make the macros easier to impl
[18:41] < shinobi-cl> mmm ok, thanks :)
[16:07] <+pugs_svn> r28778 | moritz++ | [t/spec] test for RT #69738: array
indexing with Rats
[16:08] <@moritz_> rakudo: say <a b c>[5/4]
[16:08] <+p6eval> rakudo 609cc2: OUTPUT<<bNL>>
grammar PlusMinusPerl is Perl {
token prefix:sym<+-> { <sym> }
}
Specifically, we want to be able to write parsers easily in Perl, which means
that we need some way of matching a token stream against something like a
set of regular expressions. You can think of a token stream as a funny kind of
string. So if the "given" of a switch statement is a token stream, the regular
expressions matched against it may have special abilities relating to the
current parse's data structure. All the regular expressions of such a switch
statement will likely be implicitly anchored to the current parse location,
for instance. There may be special tokens referring to terminals and
non-terminals. Basically, think of something like a yacc grammar, where
alternative pattern/action grammar rules are most naturally expressed via
switch statement cases. More on that in the next Apocalypse.
Also, it's allowed to intersperse ordinary code between the cases, in which
case the code must be executed only if the cases above it fail to match. For
example, this should work as indicated by the print statements:
given $given {
print "about to check $first";
when $first { ... }
print "didn't match $first; let's try $next";
when $next { ... }
print "giving up";
default { ... }
die "panic: shouldn't see this";
}
----------------------------------------------------------------------------
multi wins(Scissors $, Paper $) { +1 }
The only new thing here is that the parameters don't have names. Since they
are not used in the body of the subroutine anywhere, there's no use in forcing
the programmer to come up with a clever name. A C<$> in a signature just
stands for a single, anonymous scalar variable.
But Perl has often been tagged as a language in which it's easy to write
programs that are difficult to read, and it's no secret that regular expression
syntax that has been the chief culprit. Funny that other languages have been
borrowing Perl's regular expressions as fast as they can...
if 1 <= $x <= 10 {
say "$x is between 1 and 10";
}
zip operator Z (or zip() )
(1,3,5) Z (2,4,6) # ((1, 2), (3, 4), (5, 6))
reduce [...] meta-operator:
my @a = (1,2,3,4);
say [+] @a; # 10 (1 + 2 + 3 + 4)
-------------------------------
05.11.2009
[17:24] <@jnthn> :-P
[17:24] < frettled> what does that operator do?
[17:24] < PerlJam> frettled: heh!
[17:25] < PerlJam> time for a new language -- emotical
[17:25] < PerlJam> composed entirely of emoticons
[17:25] <@jnthn> rakudo: multi postfix:<:-P>($x) { say "$x neeehhh!!" }; "does this" :-P
[17:25] <+p6eval> rakudo 5e05b8: OUTPUT<<does this neeehhh!!NL>>
[17:27] < takadonet> ....
[17:28] <@jnthn> Well I guess that answer is, "the :-P operator does whatever you define it to do" :-)
[13:38] < Woodi> is p6 Data::Dumper available ?
[13:39] < rgrau`> rakudo: my $b = 4,5,6; my $a=1,2,3,$b; say $a.perl
[13:39] <+p6eval> rakudo f16c9e: [1, 2, 3, [4, 5, 6]]NL
[17:17] <@pmichaud> (sorry, too many conversations again)
[17:17] <@moritz_> 1900 UTC it is then
[17:17] >> SignOff: reid05 [Success] [#perl6]
[17:18] <@moritz_> .oO( pmichaud is a conversative :-)
[17:18] >> kidd` joins #perl6
[17:18] <@moritz_> wow, that word actually exists
[17:18] >> reid05 joins #perl6
[17:18] <@moritz_> I just wanted to make a pun on conservative
[17:19] < masak> moritz_: isn't 19:00 UTC the usual time?
[17:19] * masak confused
[17:19] <@moritz_> didn't we have 18:30 UTC usually?
g p6eval<@pmichaud> 18:30 is parrotsketch
[17:19] <@moritz_> or was that #ps?
[17:19] < masak> yes.
[17:19] <@pmichaud> 19:00 is book
[17:19] < masak> still fine by me, though.
[17:19] < masak> just not later than usual. :P
[17:20] <@pmichaud> personally, I think there's just far too much Perl 6 activity taking place for a dead language.
[17:20] <@moritz_> any starting time between 19H and 20H UTC is fine by me, then
[17:22] < masak> pmichaud: well, a minimum of activity is needed, so we can change the name of the language everywhere.
[17:23] <@pmichaud> I've already done my bit: "Rakudo" :-)
[17:23] < masak> also, don't worry, because it's all *academic* activity, which doesn't count.
[17:23] <@PerlJam> masak++
[17:23] <@pmichaud> Besides, I think we should give Perl 5 a name. "Classic Perl", perhaps. :-)
[17:23] >> mj41 joins #perl6
[17:23] <@pmichaud> "Perl: The Original Series"
[17:24] < masak> Vanilla Perl. oh wait.
[17:24] <@pmichaud> We have a winner!
[17:24] <@PerlJam> as long as we don't accidentally create the "New Perl" meme
[17:24] < jaffa4> Perl Reloaded.
[17:24] < masak> "Perl 6: a New Deal"
[17:24] <@pmichaud> Perl Overloaded.
[17:24] < jaffa4> Revenge of The Perl.
[17:24] <@pmichaud> "I for one, welcome our new Perl overloads."
[17:25] < masak> I, for one, welcome these new Perl 6 Overloads.
[17:25] <@moritz_> Vanilla Perl and Stracciatella Perl!
[17:25] < masak> dang, pmichaud is faster :)
[17:25] < jaffa4> Perl Squared.
[17:25] <@PerlJam> Perl to the Perl
[17:26] <@PerlJam> Perl is dead. Long live Perl! (oh wait, we've already been there)
[17:26] <@moritz_> I thought it wasn't dead after all :-)
[17:26] < jaffa4> Perl on a new horse.
[17:26] <@pmichaud> The Legend of the Black Perl. (Oh, wait)
[17:26] < masak> Perl: Imerial Edition.
[17:26] < jaffa4> Perl Strikes back.
[17:27] < masak> Perl: Second Coming.
[17:27] < jaffa4> Perl Renasaince.
[15:49] < colomon> This one stupid test is the only thing stopping "make spectest" from it from being a complete
success.
[15:49] <@moritz_> do you have ICU installed?
[15:50] <@moritz_> unicode.t aborts for me 5 tests before the end
[15:50] >> SignOff: xenoterracide [Remote closed the connection] [#perl6]
[15:50] < colomon> moritz_: how can I tell?
[15:50] <@moritz_> rakudo: say %*VM<config><icu>
[15:50] <+p6eval> rakudo f87efa: Use of uninitialized valueNLNL
[..]
[15:51] <@moritz_> rakudo: .say if /:i icu/ for %*VM<config>.keys
[15:51] <+p6eval> rakudo f87efa: has_icuNLicu_sharedNLicu_dirNL
[15:51] <@moritz_> rakudo: say %*VM<config><has_icu>
[15:51] <+p6eval> rakudo f87efa: 1NL
13.11.2010:
21:02 < sorear> ash_: as a general rule, if $?FOO is not implemented specially
(and very few of them are - $?POSITION comes to mind), it is
treated as BEGIN { $*FOO }
21:02 < sorear> ie it picks up the version of $*FOO visible to the compiler
21:03 < sorear> (how this works if your compiler isn't written in Perl 6 has
never been established)
31.07.2011
14:16 < sili> What is Z=>
14:16 < masak> sili: here, I'll show you.
14:16 < masak> rakudo: my %h = <a b c> Z=> <1 2 3>; say %h.perl
14:16 <+p6eval> rakudo 922500: OUTPUT«{"a" => "1", "b" => "2", "c" => "3"}»
14:17 < sili> what is that called?
14:17 < masak> sili: "zip".
14:17 < jnthn> tadzik: And how are you getting/creating the PAST::Block?
14:17 < sili> oh, okay
14:17 < masak> sili: the zip operation intermingles two or more lists into one single list.
14:17 < sili> ya, I know zip
14:17 < masak> sili: then we just realized that Z should be a metaoperator and apply to other operators, like =>
14:18 < masak> std: <a b c> Z=> <1 2 3> Z=> <α β γ>
14:18 <+p6eval> std 516268a: OUTPUT«ok 00:01 120m
14:18 < masak> niecza: say (<a b c> Z=> <1 2 3> Z=> <α β γ>).perl
14:18 <+p6eval> niecza v8-9-g2bbb19a: OUTPUT«("a" => "1" => "α", "b" => "2" => "β", "c" => "3" => "γ").list
14:18 < masak> \o/
14:19 < masak> niecza: say (<a b c> Z=> <1 2 3> Z+ <4 5 6>).perl
14:19 <+p6eval> niecza v8-9-g2bbb19a: OUTPUT«Unhandled exception: Cannot use value like Pair as a number at ...
14:19 < tadzik> jnthn: okay
14:19 < masak> ah. precedence
14:19 < jnthn> tadzik: Checking what to do :)
14:19 < masak> niecza: say (<a b c> Z=> (<1 2 3> Z+ <4 5 6>)).perl
14:19 <+p6eval> niecza v8-9-g2bbb19a: OUTPUT«("a" => 5, "b" => 7, "c" => 9).list»
14:20 < sili> masak: that produces tupes?
14:20 < sili> tuples
14:20 < tadzik> Pairs
14:22 < sili> "a" => "1" => "3" is a pair of 3?
14:22 < masak> sili: you can think of it like Lisp's list data structures.
14:22 < sili> gotcha
14:28 < sili> what's ==>
14:28 < sili> perldoc -f '==>' :(
14:28 < masak> :)
14:29 < masak> sili: it's a pipe for sending lists from one statement to another.
14:29 < jnthn> nom: 1,2,3,4,5 ==> map * - 3 ==> say
14:29 <+p6eval> nom: OUTPUT«-2 -1 0 1 2»
14:29 < jnthn> nom: 1,2,3,4,5 ==> map * - 3 ==> grep * < 0 ==> say
14:29 < sili> got it, so you don't have to write your stuff from right-to-left
14:29 <+p6eval> nom: OUTPUT«-2 -1»
14:30 < jnthn> Yeah, it can look really pretty
14:30 < masak> sili: you could think of it like a semicolon, except that the
next statement gets "primed" with values. very much like pipes in Unix.
14:30 < masak> nom: say <== grep * < 0 <== map * - 3 <== 1,2,3,4,5
14:30 < sili> long live perl6
14:30 <+p6eval> nom: OUTPUT«-2 -1»
14:30 < masak> \o/
14:30 < jnthn> masak: Unpretty. :P
14:31 < masak> jnthn: bigot! :P
14:31 < tadzik> ytterp
14:31 < masak> rakudo: say flip "pretty"
14:31 <+p6eval> rakudo 922500: OUTPUT«ytterp»
18:53 * djanatyn has been looking for ways to contribute
18:53 < masak> here's my tip: look for ways to have fun that involve Perl 6.
18:54 < masak> sooner or later, you'll find yourself doing something not only
meaningful, but something probably closely related to the
things you enjoy the most.
18:54 < pmichaud> also, don't feel as though you need our permission to do
something. :-)
18:55 < pmichaud> we can hazard guesses as to what might be useful... but we
can also be wrong.
18:56 < djanatyn> I don't know how safe it would be to give me that advice.
18:56 < djanatyn> It took me much longer than it should have to realize that
I should have been using "use strict;" ;)
19:04 < crked> Hi #perl6, I have a problem with regex in Rakudo. How can I use
negative char class to express one or more non-space?
I tried <-[ ]>+ but it seems doesn't work
19:05 < pmichaud> need to quote the space
19:05 < pmichaud> <-[\ ]>+
19:05 < pmichaud> (I think that works)
19:06 < crked> Yes, you are right. Thank you.
19:06 < pmichaud> rakudo: say 'abc def' ~~ / <-[\ ]>+ /
19:06 <+p6eval> rakudo 922500: OUTPUT«abc»
20:27 < djanatyn> so, about using this HTML::Template library that I just
installed with panda...
20:28 < djanatyn> do I use it just like I would in perl 5?
20:28 < masak> djanatyn: depends what you mean by "just".
20:28 < masak> the basics are the same: 'use HTML::Template;'
20:29 < djanatyn> Would I use "HTML::Template.new" instead of
"HTML::Template->new"?
20:30 < masak> djanatyn: you would.
20:30 < moritz> djanatyn: well yes, you need to use the Perl 6 syntax. Look at
the tests
20:30 < djanatyn> *oh*!
20:31 < djanatyn> that's what the "t" directory is :D
16:33 < jnthn> .win 17
16:33 < jnthn> oop
16:33 < jnthn> s
16:34 < jnthn> ...keyboard usage fail.
16:34 < [Coke]> esc-u is shorter. :)
16:34 * moritz tries to stay below a magic number of 15 irssi windows
16:34 < moritz> though I often fail
16:35 * jnthn blames having drunk too much coffee today
03:10 < sorear> do we still beleive Nil ~~ Parcel ~~ Any?
03:10 < pmichaud> nom doesn't have Nil ~~ Parcel
03:11 < pmichaud> nom: say Nil ~~ Parcel;
03:11 <+p6eval> nom: OUTPUT«Bool::Falseâ»
03:11 < pmichaud> although it is still Cool and Any
03:11 < sorear> nom: say Nil.WHAT
03:11 <+p6eval> nom: OUTPUT«Nilâ»
03:11 < TimToady> Nil is about the closest thing we have to a bottom value
03:11 < sorear> nom: say Nil.^parents
03:11 <+p6eval> nom: OUTPUT«Iterator() Iterable() Cool() Any() Mu()â»
23:35 < huf> _whoa_
23:36 < huf> this feature is awesome
23:36 < jnthn> huf: Which one? :)
23:36 < huf> S03:4021
23:36 < pmichaud> :)
23:36 < TimToady> well, yes :)
23:36 < pmichaud> Yes, it's awesome.
23:36 < jnthn> aha :)
23:36 < pmichaud> Perl 6 strives for awesomeness. The Perl 6 implementations
strive to catch up with that. :)
23:37 < pmichaud> nom: my %h; %h<xyz> *= 4; say %h.perl;
23:37 <+p6eval> nom: OUTPUT«("xyz" => 4).hashâ»
23:37 < thundergnat> Awesome, though a little unintuitive in some of the weird
corner cases.
23:37 < benabik> Does that actually call infix:<*>(), or does it call infix:<*>(4)?
23:38 < pmichaud> it calls infix:<*>()
23:38 < pmichaud> basically
14:18 < bbkr> hi. what is the faster way now to convert bytes to ascii char
(string "01010100" to char "T" for example)? pack("B", "01010100") says "B"
token is not recognized.
14:18 < flussence> rakudo: say chr(:2("01010100"))