gawk 3.0.95 - the "extension" function (???) 
Author Message
 gawk 3.0.95 - the "extension" function (???)

I understand that extension is completely alpha at this point and so on, but
I still can't resist playing around with it.  The docs describe it briefly,
but indicate that I need to get and read "GAWK: Effective AWK Programming"
in order to really understand it.  So, how do I get that book?  Am I correct
in assuming that I would have to pay money and get something with actual
paper in it (I.e., that it is not available online) ?

Anyway, from what I could tell from the man page, this should work.
Observe:

 %) ./gawk 'BEGIN {print extension("/lib/libc.so.6","getuid")}'
 gawk: cmd. line:1: fatal error: internal error
 Abort
 %)

getuid() is in my libc - and it is a function of no args that returns an
int - which is about as simple a test case as you could ask for.

This is on a Linux 2.2.5-15 (Red Hat) system.

Also, any clues as to what this will eventually look like?  Will you be able
to pass args to functions?  Will you be able to pack and unpack binary
structures (as we do in TAWK) ?



Tue, 19 Aug 2003 01:19:30 GMT  
 gawk 3.0.95 - the "extension" function (???)

Quote:

> I understand that extension is completely alpha at this point and so on, but
> I still can't resist playing around with it.  The docs describe it briefly,
> but indicate that I need to get and read "GAWK: Effective AWK Programming"
> in order to really understand it.  So, how do I get that book?

Try "info gawk" on the command line. If you don't have "info", try
"C-h i gawk" in (X)Emacs. If you did not have "makeinfo" installed when
you installed gawk, you probably won't have the gawk.info file
installed. Then you can either install "makeinfo" and re-make gawk, or
you can install{*filter*}and dvips and use "make gawk.ps gawkinet.ps" in
the doc directory to get the book in postscript form. All of these tools
are probably part of your Linux distribution.

Quote:
> %) ./gawk 'BEGIN {print extension("/lib/libc.so.6","getuid")}'
> gawk: cmd. line:1: fatal error: internal error
> Abort
> %)

> getuid() is in my libc - and it is a function of no args that returns an
> int - which is about as simple a test case as you could ask for.

No, please read the book, it's a bit more complicated; you can't call
arbitrary functions in arbitrary libraries ("if you want Perl, you know
where to get it"). Have a look at the PROCINFO array if you need the
(e)uid.

Regards...
                Michael



Tue, 19 Aug 2003 03:43:45 GMT  
 gawk 3.0.95 - the "extension" function (???)

...

Quote:
>Try "info gawk" on the command line. If you don't have "info", try
>"C-h i gawk" in (X)Emacs. If you did not have "makeinfo" installed when
>you installed gawk, you probably won't have the gawk.info file
>installed.

I got this to work: info -f gawk-3.0.95/doc/gawk.info

Quote:
>Then you can either install "makeinfo" and re-make gawk, or
>you can install{*filter*}and dvips and use "make gawk.ps gawkinet.ps" in
>the doc directory to get the book in PostScript form. All of these tools
>are probably part of your Linux distribution.

I think I have everything except tex.  I can install that.  I also seem to
remember at one point having tools that convert texinfo to PS directly.
Come to think of it, I think this tool ran under OS/2, which I don't think I
have anymore.  Oh well...

Quote:
>> %) ./gawk 'BEGIN {print extension("/lib/libc.so.6","getuid")}'
>> gawk: cmd. line:1: fatal error: internal error
>> Abort
>> %)

>> getuid() is in my libc - and it is a function of no args that returns an
>> int - which is about as simple a test case as you could ask for.

>No, please read the book, it's a bit more complicated; you can't call
>arbitrary functions in arbitrary libraries

Right - based on the info file, I was able to work out that the idea is that
you call a function in your lib that adds the new function to the current
running image, then you call that function.  So, the point is that you have
to write the lib yourself.  What's really cool about T-AWK is that you can
call the functions in the standard libs directly, with almost no effort.

The info file also pointed me to the extensions/ subdir in the distro, which
I had previously overlooked.

Quote:
>("if you want Perl, you know where to get it").

Actually, you should be saying, "If you want T-AWK, you know where to get
it..."  That's the standard I'm comparing against.

Quote:
>Have a look at the PROCINFO array if you need the (e)uid.

Obviously, that was just an example.  I knew about PROCINFO.

Quote:
>Regards...
>            Michael

Thanks for the help.


Tue, 19 Aug 2003 08:30:49 GMT  
 gawk 3.0.95 - the "extension" function (???)

Quote:

> Actually, you should be saying, "If you want T-AWK, you know where to get
> it..."  That's the standard I'm comparing against.

Correct me if I'm wrong, but is T-AWK open source and free? Does it run
on anything else than DOS, Windows and OS/2? What happens to your
programs if Thompson Automation stops shipping TAWK for your brand new
Windows 2002?

Calling TAWK a "standard" is a bit dubious in my eyes. GAWK runs
everywhere from your electrical tooth brush to your mainframe ;-)

Regards...
                Michael



Wed, 20 Aug 2003 01:47:08 GMT  
 gawk 3.0.95 - the "extension" function (???)

Quote:


>> Actually, you should be saying, "If you want T-AWK, you know where to get
>> it..."  That's the standard I'm comparing against.

>Correct me if I'm wrong, but is T-AWK open source and free? Does it run
>on anything else than DOS, Windows and OS/2? What happens to your
>programs if Thompson Automation stops shipping TAWK for your brand new
>Windows 2002?

Add Solaris to the list and you're there.  I would assume (though one can
never be sure) that the current Win32 versions of T-AWK will continue to
run under future verions of Windows.  And, in any case, the company is still
around - there's no reason to assume that upgrades will not be made available
if necessary.

Quote:
>Calling TAWK a "standard" is a bit dubious in my eyes. GAWK runs

If anything, I was drawing a parallel between TAWK and Perl - both of which
can be thought of as "AWK on steroids".


Wed, 20 Aug 2003 04:13:05 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. gawk 3.x: "static" extensions

2. GAWK 3.0.95 - question on the extensions stuff

3. GAWK 3.0.95 - Bug (er, problem) report on extension stuff

4. gawk 3 patch by A. Robbins for index(.,"")==0 bug

5. Bug: gawk 3.0 fails to index(.,"")

6. "Assembly in VB - in windows 95 ?"

7. "use" clauses and Ada 95 OOP

8. "Fortran 95/2003 Explained" (Errata)

9. "Fortran 90/95 Explained" by Metcalf

10. Using "exec" under Windows 95/NT

11. Q: "exec" in Windows 95

12. string.join(["Tk 4.2p2", "Python 1.4", "Win32", "free"], "for")

 

 
Powered by phpBB® Forum Software