WEBVTT

00:00.000 --> 00:16.000
So, hello everybody, I'm talking about Doc, a canoe arc, and like it says we're extending it

00:16.000 --> 00:18.000
really because we can.

00:18.000 --> 00:22.000
It's really looking at and say, do we need to?

00:22.000 --> 00:25.000
And the answer is, it doesn't matter.

00:25.000 --> 00:28.000
It's there, so we're going to go ahead and do it.

00:28.000 --> 00:37.000
So, just for a little bit of background, we have a short timeline of the sea standards,

00:37.000 --> 00:43.000
of the start of Unix and the start of time in 1970, which was in assembly and then it's

00:43.000 --> 00:44.000
which to see.

00:44.000 --> 00:52.000
In 1978, KNRC was as established as it was with the sea programming language book.

00:53.000 --> 01:01.000
In 1989, we got an actual MCC with the C89 flag, and then we've a couple other ones,

01:01.000 --> 01:03.000
every couple years.

01:03.000 --> 01:11.000
You know, new things that get added, that make things, that, you know, everything works better.

01:11.000 --> 01:12.000
Things are more defined.

01:12.000 --> 01:16.000
There's a lot less undefined behavior going on.

01:17.000 --> 01:19.000
Compare that with a short timeline of arc.

01:19.000 --> 01:24.000
It appeared in 1977, in 1988, dish.

01:24.000 --> 01:26.000
It'll hold bunch of things.

01:26.000 --> 01:32.000
Unix system 5 came out with a new arc version, and the second arc book.

01:32.000 --> 01:37.000
Apparently it's about the same time for the first release of canoe arc.

01:37.000 --> 01:43.000
And then 40-ish years later, we got the second arc programming language book.

01:43.000 --> 01:52.000
So, looking at a short overlap of the two, we have Unix's rewritten in C.

01:52.000 --> 01:54.000
We got arc.

01:54.000 --> 02:06.000
See, we got KNRC, got the new arc, got MCC, and I've been told we're here in 2025 now.

02:07.000 --> 02:13.000
So, really, when you're looking at arc, you're also looking backwards in time back at KNRC,

02:13.000 --> 02:17.000
and you end up with a lot of things that just look at and say,

02:17.000 --> 02:22.000
and who thought that was a good idea?

02:22.000 --> 02:26.000
So, I guess a little bit about me before I move on.

02:27.000 --> 02:31.000
I was at I did.

02:31.000 --> 02:36.000
It's the first programming language that, I mean, other than basic and key basic,

02:36.000 --> 02:41.000
that stuck with me was I did a C and C plus plus class in the early 2000s,

02:41.000 --> 02:50.000
and then comparing that back with the C timeline, you know, looking at C99 or so,

02:51.000 --> 02:54.000
wasn't that much.

02:54.000 --> 02:59.000
There were newer things, but that's, you end up being a,

02:59.000 --> 03:03.000
I always thought of it as my happy place, and playing with arc,

03:03.000 --> 03:05.000
really, I wasn't so happy after all with that,

03:05.000 --> 03:10.000
but it's, you know, it's about where I fell back to,

03:10.000 --> 03:15.000
normally, to this part of why I ended up trying to do this.

03:15.000 --> 03:20.000
So with arc, you end up with a collection of pattern action pairs,

03:20.000 --> 03:26.000
you have a condition and an action, and so a condition can be,

03:26.000 --> 03:30.000
and we'll go on to that afterwards, but there's a whole bunch of options for conditions,

03:30.000 --> 03:36.000
and action is whatever you want, you know, written in basically KNRC,

03:36.000 --> 03:41.000
and you can also run things before and after using a begin or end block,

03:42.000 --> 03:45.000
and as in KNRC, everything is optional.

03:45.000 --> 03:49.000
So you could have nothing, and that's a valid program, or just begin,

03:49.000 --> 03:56.000
or just end, or just the conditions, or just the actions.

03:56.000 --> 03:59.000
So other than the begin and end, we can have one of each,

03:59.000 --> 04:03.000
the different patterns are expressions or regular expressions,

04:03.000 --> 04:07.000
I can combine them together with hands or ears,

04:07.000 --> 04:12.000
you can have ranges in the patterns, you get all sorts,

04:12.000 --> 04:16.000
you get some options with all of those.

04:16.000 --> 04:18.000
So, ready with this one.

04:18.000 --> 04:23.000
This one I was looking for the word, the.

04:23.000 --> 04:27.000
So it just begins with prints, you know,

04:27.000 --> 04:30.000
print the frequency of the word, the.

04:30.000 --> 04:35.000
So here we're searching for the, we have our regular expression with the T's,

04:35.000 --> 04:41.000
so we look for capital N lowercase ones here, line count.

04:41.000 --> 04:48.000
I'm not declaring line count, I'm not declaring what kind of that it's an integer.

04:48.000 --> 04:53.000
I use it, and it's brings into existence, it starts at zero.

04:53.000 --> 04:56.000
It's just there.

04:56.000 --> 05:00.000
This one here with I equals zero, that one actually,

05:00.000 --> 05:06.000
without that cycle through when you're checking here,

05:06.000 --> 05:08.000
NF is number field.

05:08.000 --> 05:10.000
So, for example, searching through here,

05:10.000 --> 05:13.000
the patterns and test uses rejects.

05:13.000 --> 05:17.000
That's five, but you've already searched everything in this line.

05:17.000 --> 05:20.000
So you're already at two, four, six, seven-ish.

05:20.000 --> 05:24.000
So you get here, you're at I equals eight, or so.

05:24.000 --> 05:26.000
You're not searching anything anymore.

05:26.000 --> 05:27.000
So you actually have to reset it.

05:27.000 --> 05:29.000
So you end up with a bunch of things where

05:29.000 --> 05:33.000
you can just say, it, you know,

05:33.000 --> 05:37.000
line count brings into existence when I, when I want it,

05:37.000 --> 05:39.000
but unless you actually initialize it,

05:39.000 --> 05:42.000
you end up with running into problems.

05:42.000 --> 05:44.000
Same thing with the semicolons at the end of line.

05:44.000 --> 05:47.000
You actually don't need them.

05:47.000 --> 05:54.000
So I don't know if anyone is actually counting the number of times that the occurred.

05:54.000 --> 05:59.000
So it looks like the occurred on two lines and five times.

05:59.000 --> 06:02.000
And then using prep dash C for the,

06:02.000 --> 06:05.000
prep degrees that it was on two different lines.

06:05.000 --> 06:06.000
So I'm not going to go back.

06:06.000 --> 06:08.000
I'm just going to assume that that was actually the case.

06:08.000 --> 06:13.000
I don't remember where it was with that.

06:13.000 --> 06:15.000
Fizz buzz.

06:15.000 --> 06:18.000
You know.

06:18.000 --> 06:20.000
I mean, like it says, you print fizz,

06:20.000 --> 06:23.000
if it's number of line, if it's divisible by three,

06:23.000 --> 06:27.000
buzz if it's divisible by five, both.

06:27.000 --> 06:31.000
If it's divisible by both of them.

06:31.000 --> 06:34.000
So no pattern.

06:34.000 --> 06:39.000
And so just go straight straight into the action here,

06:39.000 --> 06:44.000
between nine and 15 and NR is number of record.

06:44.000 --> 06:49.000
It counts how many basically how many lines you've gone through.

06:49.000 --> 06:51.000
So far while reading.

06:51.000 --> 06:56.000
So we just say if it's, if NR module of three is divisible by zero,

06:56.000 --> 07:02.000
if the remainder is zero, then add on fizz.

07:02.000 --> 07:07.000
If it's five add on buzz and then print the output line.

07:07.000 --> 07:13.000
And again back at 11, we reset it again to the line number with the space.

07:13.000 --> 07:16.000
So here there's no concatenating strings.

07:16.000 --> 07:20.000
We just have output equals output fizz or buzz.

07:20.000 --> 07:26.000
There's no plus, there's no dot, there's no concatenation.

07:26.000 --> 07:29.000
It's just, it's just there.

07:29.000 --> 07:31.000
You have a white space between it.

07:31.000 --> 07:35.000
And it gets merged in together.

07:35.000 --> 07:41.000
And you see that, it looks like it works.

07:41.000 --> 07:49.000
But yeah, so it's, you know, ended up looking at the manual constantly to figure out.

07:49.000 --> 07:53.000
How, how does this exactly work?

07:53.000 --> 07:57.000
So there are some built-in variables that you end up with.

07:57.000 --> 07:59.000
I don't think this was the full list.

07:59.000 --> 08:03.000
This was the list at least in the first off book.

08:03.000 --> 08:09.000
If number of records, file number of records was,

08:09.000 --> 08:13.000
this was if you were reading multiple files.

08:13.000 --> 08:17.000
Then if the first file had 100 records, the second file had 100 records,

08:17.000 --> 08:24.000
the third file of the second, the third record of the second file would have an FNR of 3,

08:24.000 --> 08:29.000
and an R of 103.

08:29.000 --> 08:37.000
Other ones, the number of fields, file name, field separator, and record separator.

08:37.000 --> 08:46.000
So using this as an example with the FS, there's an actual string for,

08:46.000 --> 08:50.000
you know, I guess, rejects for what the field separators are.

08:50.000 --> 08:55.000
But the space between the D and the S and field separator is a break.

08:55.000 --> 08:59.000
And between the FS and the field, all of that space counts as one break.

08:59.000 --> 09:04.000
So you don't end up with a problem like you would have split that with cut.

09:04.000 --> 09:08.000
We'd say, okay, let me count how many spaces there are between FS and field.

09:08.000 --> 09:11.000
You say, here's a white space.

09:11.000 --> 09:15.000
Plus, dash is one field, FS is one field, field is one field.

09:15.000 --> 09:19.000
Separator is one field.

09:19.000 --> 09:21.000
So you can go and change that to use commas.

09:21.000 --> 09:25.000
If you want it to use CSV or other things like that,

09:25.000 --> 09:28.000
record separator default is a new line.

09:28.000 --> 09:31.000
But you can actually set it to say two new lines.

09:31.000 --> 09:35.000
And then if you just have a paragraph of things, you can say,

09:35.000 --> 09:38.000
well, this four line segment is one record,

09:38.000 --> 09:44.000
and then you separate it differently, and you can parse addresses that way.

09:44.000 --> 09:50.000
And then you can also set the output field separator and stuff

09:50.000 --> 09:53.000
for actually printing at the end.

09:53.000 --> 09:57.000
You can make self-contained ox grips.

09:57.000 --> 10:02.000
Dash F, and we're actually using short flags because, you know,

10:02.000 --> 10:05.000
that's the way it is.

10:05.000 --> 10:09.000
And it really does just print itself.

10:09.000 --> 10:13.000
It seems like press the wrong direction.

10:13.000 --> 10:17.000
Then I guess in terms of actually extending it, there were a couple of ways.

10:17.000 --> 10:22.000
This one, we're switching the case letter by letter of the incoming text.

10:22.000 --> 10:26.000
So there is a two upper and two lower function.

10:26.000 --> 10:29.000
So I for the array, we're just, so we're splitting.

10:29.000 --> 10:32.000
$0 is the full incoming text.

10:32.000 --> 10:37.000
We're splitting it into the array, my input, and iterating through it.

10:37.000 --> 10:40.000
And if it's capital, make it lower case, if it's lower case,

10:40.000 --> 10:44.000
make it capital, printed out at the end.

10:44.000 --> 10:47.000
So here's the actual thought for thought.

10:47.000 --> 10:55.000
Here's the actual code for switching the cases.

10:55.000 --> 11:00.000
So comparing, so here come through 15, we say,

11:00.000 --> 11:04.000
we're checking, my input, we're checking, is it lower case,

11:04.000 --> 11:07.000
make it up for case, otherwise make it lower case.

11:07.000 --> 11:10.000
Here was, sorry, went the wrong way again.

11:10.000 --> 11:13.000
Here we're saying we're passing it through this function called switcher,

11:13.000 --> 11:16.000
which we've brought out here into switcher.ock,

11:16.000 --> 11:21.000
where two through six or seven is the same function.

11:22.000 --> 11:28.000
We're just going to, we've pulled it out and put it in a separate file.

11:28.000 --> 11:33.000
And so we'd say, goc-f, our second file,

11:33.000 --> 11:36.000
and we're including the switcher one that we've pulled out.

11:36.000 --> 11:39.000
And we can actually useock paths to say,

11:39.000 --> 11:43.000
actually, all of my library code is in this file,

11:43.000 --> 11:50.000
is in this directory called include, just use dash i switcher.ock in this case.

11:51.000 --> 11:56.000
So defaultock path is, you know, user local shareock.

11:56.000 --> 12:03.000
And, you know, the filter has me here at the time.

12:03.000 --> 12:08.000
So it, you search everything there, you can write a library

12:08.000 --> 12:11.000
and actually just stick it there and reference it from other things.

12:11.000 --> 12:19.000
And, you get, you know,

12:19.000 --> 12:22.000
and, you know, it can get switch based on the prefix,

12:22.000 --> 12:24.000
as how you've compiled gawk.

12:24.000 --> 12:29.000
The other one that's different specific to gawk is oclib path,

12:29.000 --> 12:35.000
where you have user local lib gawk instead of user local shareock.

12:35.000 --> 12:39.000
And so these ones are actually compiled files,

12:39.000 --> 12:42.000
and they are loaded instead of included.

12:42.000 --> 12:45.000
So difference here would be,

12:46.000 --> 12:49.000
so here, very similar to the previous one,

12:49.000 --> 12:52.000
except here online three, we have outload switcher,

12:52.000 --> 12:54.000
which is a library that I've written for this,

12:54.000 --> 12:57.000
and we're doing the same output equals output,

12:57.000 --> 13:00.000
c switcher, my input i.

13:00.000 --> 13:05.000
And so, beginning we have, according to gawkapi.h,

13:05.000 --> 13:08.000
just a series of includes,

13:08.000 --> 13:12.000
because it includes literally nothing just in case,

13:12.000 --> 13:17.000
you're using an old system that doesn't have any of those.

13:17.000 --> 13:20.000
And so, you know, I've just put in the notes,

13:20.000 --> 13:22.000
beginning of header end of header,

13:22.000 --> 13:25.000
because of how it works, so we've gone into clear the functions

13:25.000 --> 13:27.000
that I was going to make.

13:27.000 --> 13:31.000
And then, here's the bottom part of the file,

13:31.000 --> 13:33.000
it registers it,

13:33.000 --> 13:38.000
and there's no initialization required when running the function.

13:38.000 --> 13:43.000
It adds switcher to the function table.

13:43.000 --> 13:47.000
And then in terms of actually switching the things,

13:47.000 --> 13:51.000
this one actually ended up running into all sorts of issues

13:51.000 --> 13:53.000
and then to being, you know,

13:53.000 --> 13:55.000
where I said, see, actually it turns out,

13:55.000 --> 13:58.000
isn't my happy place.

13:58.000 --> 14:01.000
So yeah, so it really just, I mean,

14:01.000 --> 14:04.000
there is the two upper two lower and ways to compare,

14:04.000 --> 14:06.000
but I ended up doing it this way.

14:06.000 --> 14:11.000
So, so the main part here is,

14:11.000 --> 14:13.000
you know, other than here on 23,

14:13.000 --> 14:16.000
where we have the defining the function,

14:16.000 --> 14:18.000
we have our actual, we're getting our argument,

14:18.000 --> 14:20.000
which is an ox string,

14:20.000 --> 14:23.000
and we're extracting the first letter

14:23.000 --> 14:25.000
because we know we're passing it letter by letter

14:25.000 --> 14:27.000
and we're using K and RC,

14:27.000 --> 14:29.000
so we can literally do whatever we want.

14:29.000 --> 14:31.000
So we're just going to ignore that it's a string,

14:31.000 --> 14:33.000
pretend it's a character array,

14:34.000 --> 14:36.000
and grab our letter,

14:36.000 --> 14:39.000
and then we're going to test it out.

14:40.000 --> 14:44.000
I had some magical thing I ran into

14:44.000 --> 14:46.000
that I couldn't get to work,

14:46.000 --> 14:50.000
so I recreated a ox string

14:50.000 --> 14:54.000
and stuck my letter back in the magic spot

14:54.000 --> 14:56.000
where I said it was going to be,

14:56.000 --> 15:00.000
and I ran in,

15:00.000 --> 15:04.000
suddenly it started working almost.

15:04.000 --> 15:07.000
So I got my ABCDE123 to switch,

15:07.000 --> 15:09.000
and then I ran it through again,

15:09.000 --> 15:12.000
and I have a double-free.

15:12.000 --> 15:16.000
So, I'd love to know where it was,

15:16.000 --> 15:20.000
I don't think I'm going to return to that code.

15:20.000 --> 15:23.000
That's 23ish, 24 lines,

15:23.000 --> 15:26.000
I've managed to make a double-free error,

15:26.000 --> 15:28.000
so lots of fun with that,

15:28.000 --> 15:32.000
but I mean, everything is in Gok API.H.

15:32.000 --> 15:33.000
When you install Gok,

15:33.000 --> 15:36.000
it includes the API header,

15:36.000 --> 15:40.000
and it tells you all of the things

15:40.000 --> 15:42.000
that you can get with it.

15:42.000 --> 15:44.000
This one was the ox string,

15:44.000 --> 15:47.000
it has a, has a string in the length.

15:47.000 --> 15:53.000
Number types are either doubles or MPFR.

15:53.000 --> 15:56.000
Number thing is,

15:57.000 --> 16:00.000
for the fancier math.

16:00.000 --> 16:03.000
All numbers are doubles,

16:03.000 --> 16:07.000
which becomes fun.

16:07.000 --> 16:10.000
This one was the loading the function.

16:10.000 --> 16:11.000
I'm going to skip that.

16:11.000 --> 16:13.000
Is it a number or a string?

16:13.000 --> 16:15.000
The answer is yes.

16:15.000 --> 16:17.000
It is a number and a string,

16:17.000 --> 16:22.000
and ox value is what ox works on,

16:22.000 --> 16:24.000
and you can see it is,

16:24.000 --> 16:27.000
I mean, you can declare what it is,

16:27.000 --> 16:30.000
but it's a string and a number and an array,

16:30.000 --> 16:34.000
and it can also be a scalar or a Boolean.

16:34.000 --> 16:36.000
It is all of them,

16:36.000 --> 16:39.000
depending on how you interact with it.

16:39.000 --> 16:45.000
Let's go and skip that part.

16:45.000 --> 16:50.000
There are some fun programs written in Gok TranslateShell.

16:50.000 --> 16:55.000
That checks uses curl to do translation in the terminal,

16:55.000 --> 16:59.000
and so it does,

16:59.000 --> 17:02.000
you know, a frame I think we have to still.

17:02.000 --> 17:03.000
Okay.

17:03.000 --> 17:04.000
We'll say check that out.

17:04.000 --> 17:05.000
Shepard run.

17:05.000 --> 17:08.000
I wrote and had lots of fun with that.

17:08.000 --> 17:10.000
So, yeah.

17:10.000 --> 17:13.000
Let me switch quickly to,

17:13.000 --> 17:18.000
You got it done, really.

17:19.000 --> 17:21.000
And there's Gok Explive,

17:21.000 --> 17:23.000
which I did not make a slide for,

17:23.000 --> 17:26.000
but here there's a collection of extensions

17:26.000 --> 17:31.000
for working with Postgres or with CSVs or with JSON,

17:31.000 --> 17:34.000
or Redis XML, everything,

17:34.000 --> 17:38.000
and people working together to actually create libraries

17:38.000 --> 17:40.000
to work with us,

17:40.000 --> 17:43.000
that work generally with the upload function.

17:43.000 --> 17:46.000
And you think, well, who would do this?

17:47.000 --> 17:48.000
Yeah.

17:48.000 --> 17:50.000
Go ahead, have fun.

17:50.000 --> 17:54.000
Look out for double-free hours.

17:54.000 --> 17:55.000
Awesome.

17:59.000 --> 18:01.000
He keeps all right.

