winfredraj | hello all, I am trying some examples for a TCP server and I am trying to print the raw buffer but the whole buffer is not shown when say($buf) is used | 04:33 | |
what else will show the whole buffer? | |||
dd shows things better | 04:35 | ||
07:59
dakkar joined
|
|||
antononcube | @winfredraj Maybe converting the content $bug would produce better results? | 12:38 | |
winfredraj | or will I be able to receive it with encoding | 12:42 | |
? | |||
$buf = $conn.recv(:bin) is what is in the example | |||
it would be nicer if I can get that in utf8, then I can use the Raku grammar magic to full use | 12:43 | ||
I am able to receive it as utf8 in Dlang but I will have to use the PEGGED module there - but after getting used to Raku grammars it is very difficult to use anything else | 12:44 | ||
it sort of spoils you | 12:45 | ||
antononcube | Here is link of what I found to work for images (similar to what you wrote above): github.com/antononcube/Raku-Image-...akumod#L76 | ||
winfredraj | thank you sir, let me look it up | ||
multi method new( :$localhost, :$localport, :$family = PF_INET, :$listen, :$encoding = 'utf-8', :$nl-in = "\r\n", --> IO::Socket::INET:D) | 13:27 | ||
does this mean that utf8 is the default encoding in this method? | |||
antononcube | Most likely. This can be verified with a suitable test. | 13:29 | |
lizmat | m: sub a(:$encoding = "foo") { say $encoding }; a | ||
camelia | foo | 13:30 | |
winfredraj | thanks | 13:32 | |
13:48
dakkar left
13:55
dakkar joined
14:04
dakkar left,
Heptite joined
14:05
dakkar joined
16:21
Heptite left
|
|||
wow, I didnt know that you can pass a function to an WHERE clause to sanitize an argument, but seems to work - does it lead to performance problems? | 16:32 | ||
I am asking because I remember Jonathon talking about (lot of) WHERE clauses causing things to slow down with multiple dispatch | 16:33 | ||
dont want to go overboard and sprinkle too much of those | |||
m: sub ten(){return 10};sub test(Int $a where ten() < * <= 20, Int $b where * >20){say "OK: $a $b";};test(15,30) | 16:35 | ||
Raku eval | OK: 15 30 | ||
16:35
dakkar left
|
|||
winfredraj | m: sub ten(){return 10};sub test(Int $a where ten() < * <= 20, Int $b where * >20){say "OK: $a $b";};test(9,30) | 16:36 | |
Raku eval | Exit code: 1 Constraint type check failed in binding to parameter '$a'; expected anonymous constraint to be met but got Int (9) in sub test at main.raku line 1 in block <unit> at main.raku line 1 | ||
antononcube | I think that particular part of multiple dispatch was optimized. | 16:39 | |
winfredraj | m: my $a = Buf[uint8].new(0xA2,0xB6);$a.decode('UTF-8') | 18:22 | |
Raku eval | Exit code: 1 Malformed UTF-8 at line 1 col 1 in block <unit> at main.raku line 1 | ||
winfredraj | Hello, how can use this particular exception in a CATCH block so that I can catch this exception accurately | 18:23 | |
I mean, how can I find out what sort of a exception it is | |||
so that I can use a given to catch just this exception | 18:26 | ||
m: {my $a = Buf[uint8].new(0xA2,0xB6);$a.decode('UTF-8')}; CATCH {default {.WHAT.say;}} | 18:32 | ||
Raku eval | (AdHoc) | ||
antononcube | @winfredraj I think you already getting what you are looking for. Look into the structure of the failure object. | 19:14 | |
For example, what you see with CATCH {default {.raku.say;} ? | |||
winfredraj | ja, got it thanks | 19:15 | |
antononcube | I think there is payload attribute. | ||
winfredraj | @antononcube - are not all arguments passed as Value in Raku? | 19:16 | |
or do we have any exceptions there? | |||
for example, for Buf[uint8] etc | |||
antononcube | Yes, by value, but you can use rw. | 19:17 | |
sub modify-reference($x is rw) { $x = 10; } | 19:18 | ||
Hmm... Buf[uint8] is a concretization of a generic class... | 19:19 | ||
You can also use rw to class attributes. | 19:22 | ||
docs.raku.org/type/Attribute#trait_is_rw | 19:23 | ||
winfredraj | say $buf; say is_it_malformed($buf); say "After:"; say $buf; | ||
the first say shows me the contents, but the 2nd say does not | |||
sorry -let me do a few more checks | 19:25 | ||
maybe I was wrong, sorry | |||
librasteve | hi arundel sounds great … maybe you can make an issue or pr over there and provides some basic examples and i can chime in?? | 19:31 | |
21:01
teatime joined
|