🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
kleb howdy folks! I am writing a simple parser to port a function from one language to another -- basically what I want is for the parsing script to convert the whole signature from c++ to rust, writing a TODO at the top of the commented body.  The entire thing is almost working except for one thing: I am having trouble figuring out how to write a 01:28
grammar rule for "the entire function body, including surrounding curly braces"
I would like to be able to write something like: ```raku
rule bracketed-function-body { '{' <function-body> '}' }
rule function-body { .* } 01:29
or something like that
kleb i can control the input text such that i can guarantee exactly one function and body is the program input 01:30
kleb when i do that, the rule for "function-body" looks like it is starting to work, but with Grammar::Tracer I can see it stop short, for apparently no reason 01:33
kleb does anybody know why these grammar rules are incorrectly parsing? thanks in advance for any help 01:35
kleb nevermind! I am going to manually split it up with simple searching and string splitting as a preliminary step 01:52
jmerelo m: dd % (1,2,3,4) 06:32
camelia 5===SORRY!5=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> 3dd %7⏏5 (1,2,3,4)
expecting any of:
infix
infix stopper
postfix
statement end
statement modifier…
jmerelo m: dd % .new(1,2,3,4) 06:33
camelia Hash element = {"1" => 2, "3" => 4}
jmerelo m: dd $ .new(1,2,3,4)
camelia Default constructor for 'Any' only takes named arguments
in block <unit> at <tmp> line 1
jmerelo m: dd .new(1,2,3,4) 06:34
camelia Default constructor for 'Any' only takes named arguments
in block <unit> at <tmp> line 1
jmerelo m: dd + .new(1,2,3,4)
camelia Default constructor for 'Any' only takes named arguments
in block <unit> at <tmp> line 1
jmerelo m: say |(1,2,$(3,4)) 06:47
camelia 12(3 4)
jmerelo m: say |(1,2,my $ = (3,4))) 06:53
camelia 5===SORRY!5=== Error while compiling <tmp>
Unexpected closing bracket
at <tmp>:1
------> 3say |(1,2,my $ = (3,4))7⏏5)
jmerelo m: say |(1,2,my $ = (3,4))
camelia 12(3 4)
jmerelo We're preparing a proposal for Google's season of docs: perl-foundation-outreach.github.io...ocs-ideas/ Contribute by joining as a mentor, or with new ideas 08:26
lizmat clickbaits rakudoweekly.blog/2021/03/22/2021-...mes-begin/ 10:32
MasterDuke finally got around to watching the fosdem videos, all very good 13:40
summerisle is there a default IO::Handle for STDOUT/STDIN available? 17:10
i recall seeing it somewhere but i can't find it in the docs
also thanks raydiak++ for reporting that
codesections m: dd $*OUT
camelia Handle element = IO::Handle.new(path => IO::Special.new("<STDOUT>"), chomp => Bool::True, nl-in => $["\n", "\r\n"], nl-out => "\n", encoding => "utf8")
tellable6 2021-03-22T02:28:08Z #raku-dev <tbrowder> codesections new release of Math::FractionalPart has routine as discussed...comments welcome, never too late for changes prior to v1. 17:11
summerisle ah
summerisle for some reason i was thinking $*STDOUT 17:11
codesections yeah, I could see it being either, honestly 17:12
The variables page in the docs site has a full list
(which I end up checking often :D) 17:13
summerisle same 17:18
guifa2 me: "0 .. $foo". me: "oops, that's one too many, make it 0 .. $foo - 1". Comma: NO, you can rewrite $foo - 1. Me: "Okay, fine, 0 ..^ $foo". Comma: NO, you can rewrite 0..^$foo). Me: .... 17:21
codesections it really wants ^$foo, I guess? Seems a bit prescriptive 17:23
speaking of things I keep needing to look up, I can never seem to keep the names of &squish and :squash straight in my head 17:33
raydiak summerisle: np, it was a fun little bug hunt. the real credit goes to vrurg++ for the swift patch 17:34
summerisle absolutely
moon-child I've never been able to handle development tools that critique my code as I type 17:37
syntax highlighting, yes; compilation warnings, yes; but that sort of thing would drive me insane
codesections moon-child: I've used them, and they don't drive me insane. But I've moved away from them -- imo, people underestimate how distracting popups like that are/overestimate how much they can multitask 17:40
codesections says hypocritically, as he splits attention between coding and IRC 17:40
moon-child popups, yeah. I've also tried to use autocomplete, but am generally unable to use it usefully 17:41
nice at the shell prompt, but it's very easy to predict what's going to happen there
codesections agreed
raydiak I can be a bit stuck in my ways, but those things feel to me like a mountain bike with training wheels... 17:42
moon-child It's--I feel like autocompletion has a lot of potential. Maybe if languages like hazel become mainstream it'll be better
codesections I'm not familiar with that one
moon-child it uses a structured editor with typed holes
moon-child so, you edit essentially the ast 17:43
codesections Ah. So the file is _never_ in an invalid state, right? I must have heard of that and just forgotten the name
guifa2 codesections: It just does a little underline letting me know that. There's options to clean up code, but in this case, it *was* absolutely right. ^$foo was much clearer in the context 17:44
moon-child meaning that in a context like 'x + y', you specify the '+' first, and then it already knows that x and y have to be arithmetic
codesections (or there's something else with same idea)
moon-child you might be thinking of paredit?
codesections no, I was thinking of a language – I wouldn't mix that up with paredit, since I use that every day! 17:45
(well, smartparens, but still)
moon-child ah, huh. I don't know then 17:46
codesections yeah, it must have been Hazel and the name didn't stick. The phrase 'typed holes' rings some bells, and hazel seems to be the only language that comes up when I search that term 17:48
japhb moon-child: Years ago when I took a course in Android dev (without bothering to get really good at Java first), I discovered that the autocomplete was so good -- and ancient Java so incredibly redundant -- that quite literally about half of the source code had been generated by the autocomplete. I would type a couple characters, try the autocomplete, and blam, almost always worked. 19:55
moon-child that's horrifying 19:58
codesections m: Int.?abs 21:40
camelia Invocant of method 'abs' must be an object instance of type 'Int', not
a type object of type 'Int'. Did you forget a '.new'?
in block <unit> at <tmp> line 1
codesections should the `.?` operator prevent that error, or am I misunderstanding how it's supposed to work? 21:41
(I ran into that trying to look up an attribute in a custom type that could be either an instance or a type object, and thought `.?` would save me) 21:42
codesections ((Also, Johnathan's recent post was the first time I'd heard the name "the call me, maybe" operator for `.?`. I'm not sure who came up with that, but they deserve a medal :D)) 21:44
moon-child codesections: .? saves you from a method whose name isn't present, like 21:53
m: 5.?lsdkjfl
camelia ( no output )
moon-child (personally, I think that's a lot less useful than what you wanted it to be, but ¯\_(ツ)_/¯)
codesections yeah, I get that, but isn't the .abs method "not present" on Int:U? 21:54
sure, it's present on Int:D, but...
japhb moon-child: It's useful for chaining: $obj.foo.?bar.?baz.?quux 21:55
If the return from $obj.foo might be a usable object or might be a Failure or Nil or somesuch.
moon-child codesections: it's a multi method
japhb: that doesn't really help, though 21:56
m: Nil.?abs
camelia Use of Nil in numeric context
in block <unit> at <tmp> line 1
japhb Or alternately if the return from $obj.foo might be one of two different types, only one of which can handle the chain of following method calls.
codesections I mean, I get that. But we could have it throw the right sort of error to be caught by `.?`, rigth? 21:57
codesections I guess I'm asking if there's a design reason to _not_ have .? catch :D methods on :U types, or if it's just a nice-to-have feature that no one has gotten around to adding yet 21:58
ugexe eh anytime i try to chain with .? it ended up backfiring
japhb moon-child: I'm guessing that's a matter of "too many things are Cool". :-( 21:59
japhb ugexe: I've used it productively, but I don't use it that often. 21:59
moon-child japhb: wh-oh--why is Nil Cool?
moon-child personally doesn't think that Nil is particularly cool 22:00
ugexe m: say Int.?foo.?Int
camelia Use of Nil in numeric context
0
in block <unit> at <tmp> line 1
japhb moon-child: I don't know the answer to that. I dunno if there's a reason or an accident of history there. 22:01