Aliased subs with prototypes
I generally like to call subroutines without redundant parens most of the time, e.g. greet "world"; If I use an alias to poke a sub into the symbol table I lose that ability and thus can't treat that sub as another other "first class" sub, *main::greet = sub { print "Hello ", shift }; greet "world"; produces, String found where operator expected at -e line 2, near "greet "world"" (Do you need to predeclare greet?) Adding a dummy sub greet {} illicits the predictable "subroutine redefined" warning. Thus, sub greet {} { no warnings; *main::greet = sub { print "Hello ", shift }; } greet "world"; Is there some way to avoid these contortions, aside from acceding to the paren monster? Paul (if not, hoping this is Yet Another Thing that'll Get Fixed in Perl 6) -- Paul Makepeace ... http://paulm.com/ "If I go to bed early, then all would be revealed." -- http://paulm.com/toys/surrealism/
Re: [JOB] Senior Perl Programmer (part onsite), United Kingdom, London (fwd)
On Friday 21 Dec 2001 18:33 pm, the might poet Dave Cross said on the wire: -> [cut] -> -> Although I thought that Sports.com only bought the Sportal brand, not -> actually any of the codebase. -> On a point of order, the Sportal brand was bought by Ukbetting plc, who also own my current employers ... Cheers, Steve -- Stephen Cardie | [EMAIL PROTECTED] sportinglife.com, Central Park, New Lane, Leeds LS11 5DZ Tel: +44 113 220 4906 | Std Disclaimers Apply All through with the niceness and negotiation stuff
Re: Aliased subs with prototypes
Paul Makepeace wrote: > If I use an alias to poke a sub into the symbol table I lose that > ability and thus can't treat that sub as another other "first > class" sub, > Adding a dummy sub greet {} illicits the predictable "subroutine > redefined" warning. > Is there some way to avoid these contortions, aside from acceding to the > paren monster? sub greet ($); # prototype (declaration, not definition) # and later... *greet = sub ($) { print "Hi, ", shift, "\n" }; # and later still... greet 'me'; Damian
Re: Aliased subs with prototypes
On Mon, Dec 24, 2001 at 12:30:36AM -0800, Paul Makepeace wrote: > Adding a dummy sub greet {} illicits the predictable "subroutine > redefined" warning. Thus, > > sub greet {} > { no warnings; > *main::greet = sub { print "Hello ", shift }; > } > greet "world"; > > Is there some way to avoid these contortions, aside from acceding to the > paren monster? gamma:/tmp $ cat greet #!/usr/bin/perl -w sub greet; # pre-declare, don't pre-define *main::greet = sub { print "Hello ", shift }; greet "world"; gamma:/tmp $ perl greet Hello worldgamma:/tmp $ Or am I missing something?? (I thought you mentioned prototypes somewhere?). -- Chris Benson
Re: Aliased subs with prototypes
On Mon, Dec 24, 2001 at 09:59:08AM +, Chris Benson wrote: > sub greet;# pre-declare, don't pre-define Ah, that's it. Thanks Chris & Damian! Paul, /me scolds himself, "shoulda RTFM!" -- Paul Makepeace ... http://paulm.com/ "What is real? Drowning in a sea of dreams." -- http://paulm.com/toys/surrealism/
Re: Aliased subs with prototypes
On Mon, 24 Dec 2001, Paul Makepeace wrote: > On Mon, Dec 24, 2001 at 09:59:08AM +, Chris Benson wrote: > > sub greet; # pre-declare, don't pre-define > > Ah, that's it. Thanks Chris & Damian! You have to tell the compiler what's going on at compile time. The subroutine isn't declared until run time, at which point 'greet "hello"' has already been parsed. The predeclaration gives the hint to the compiler it needs. An alternative is: BEGIN { *main::greet = sub { print "Hello ", shift }; } greet "world"; This is Perl. There Is More Than One Way To Do It ;-) Later. Mark. -- s'' Mark Fowler London.pm Bath.pm http://www.twoshortplanks.com/ [EMAIL PROTECTED] ';use Term'Cap;$t=Tgetent Term'Cap{};print$t->Tputs(cl);for$w(split/ +/ ){for(0..30){$|=print$t->Tgoto(cm,$_,$y)." $w";select$k,$k,$k,.03}$y+=2}
Re: Aliased subs with prototypes
On Mon, Dec 24, 2001 at 11:28:48AM +, Mark Fowler wrote: > On Mon, 24 Dec 2001, Paul Makepeace wrote: > > > On Mon, Dec 24, 2001 at 09:59:08AM +, Chris Benson wrote: > > > sub greet;# pre-declare, don't pre-define > > > > Ah, that's it. Thanks Chris & Damian! > > You have to tell the compiler what's going on at compile time. The > subroutine isn't declared until run time, at which point 'greet "hello"' > has already been parsed. The predeclaration gives the hint to the > compiler it needs. An alternative is: > > BEGIN { >*main::greet = sub { print "Hello ", shift }; > } > > greet "world"; > > This is Perl. There Is More Than One Way To Do It ;-) And another way is use subs "greet"; -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net
Filing Systems was Re: Dual boot
Paul Makepeace <[EMAIL PROTECTED]> writes: > On Fri, Dec 21, 2001 at 01:47:37AM +, robin szemeti wrote: > > Windows > > Virus > > "No effective file permisions system" > > Windows NT has a more sophisticated file ownership/permissions system > than *nix by a lng way. (Win 9x/ME suck of course.) This isn't strictly true. Different versions of UNIX have different filing systems and some, for example the modern Solaris UFS, have access control lists separate of permissions (fairly pointless in my opinion and most don't even bother using groups) and journaling etc. Also it still seems quite common to use FAT32 rather than NTFS still on many NT systems. -- Steve Mynott <[EMAIL PROTECTED]>
Re: Filing Systems was Re: Dual boot
* Steve Mynott ([EMAIL PROTECTED]) wrote: > > using groups) and journaling etc. Also it still seems quite common to > use FAT32 rather than NTFS still on many NT systems. > IIRC, Win32 admin types tend to use FAT32 for the equivalent of the / partition, i.e. c:\ , for c:\windows and all that crap. and then use NTFS on data "drives", i.e. d:\ etc. As i type this in, yet again i realise what a steaming pile of shit windows is when it comes to the most simple things. Greg -- Greg McCarroll http://217.34.97.146/~gem/
Re: Filing Systems was Re: Dual boot
On Mon, Dec 24, 2001 at 05:06:57PM +, Greg McCarroll wrote: > > As i type this in, yet again i realise what a steaming pile of shit > windows is when it comes to the most simple things. viz. Installed game of GF's PC last night. Install failed because it can't read the CD. Burnt a copy CD (on a linux box that can read the CD), tried to re-install: can't - it will only 'update'. Uninstall (with InstallShield and Control Panel) no difference. Remove all files and registry entries pertaining, no difference. Can I find out WTF it is looking at? Nope. On Un*x it's 10 seconds: strace target-program | grep '^open' | less I've spend over 6 hours[*1] on this piece of sh*t for one crappy game. And I'm nowhere (and the GF will be back from Finland next week and the game won't install) Aaaargh! I swore months ago I would not touch that machine, but I keep forgetting how crap it really is. *1 Half of which is probably waiting for reboots! -- Chris Benson