Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Do you have much use for formats, protos, ties,...?

Reply
Thread Tools

Do you have much use for formats, protos, ties,...?

 
 
kj
Guest
Posts: n/a
 
      03-13-2005



I do a lot of Perl programming, and yet there are many Perl features
that I *never* find a use for, and I wonder whether this is because
these features are inherently not very useful, or it's me who is
being just too dense to realize what I'm missing. In decreasing
order "remoteness from everyday programming":

1. formats

2. prototypes

3. operator overloading

4. tied variables

I'm curious whether other Perl programmers find these feature
useless as I do, and if not (as is likely) when do you find any of
these features truly handy? I.e. what kind of programming task
would become for you significantly more difficult (or plain less
fun) to code if the feature were not available?

kj

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
 
Reply With Quote
 
 
 
 
Chris Mattern
Guest
Posts: n/a
 
      03-13-2005
kj wrote:

>
>
>
> I do a lot of Perl programming, and yet there are many Perl features
> that I *never* find a use for, and I wonder whether this is because
> these features are inherently not very useful, or it's me who is
> being just too dense to realize what I'm missing. In decreasing
> order "remoteness from everyday programming":
>
> 1. formats


I actually used this once, but looking back at it, I should have
just used printf.
>
> 2. prototypes
>
> 3. operator overloading


In fact, you're already using this; you just don't know it. Perl does a
lot of behind-the-scenes stuff with overloading. And with tied
variable (see next), you're automatically using overloading; that's
how tying works.
>
> 4. tied variables


Now, this, on the other hand, is truly useful. I just finshed a
program that reads and rewrites selected lines in a data file.
Tie::File was *very* useful for this.
>
> I'm curious whether other Perl programmers find these feature
> useless as I do, and if not (as is likely) when do you find any of
> these features truly handy? I.e. what kind of programming task
> would become for you significantly more difficult (or plain less
> fun) to code if the feature were not available?
>
> kj
>


--
Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      03-13-2005
Chris Mattern <> wrote:
> kj wrote:
>
>>
>> I do a lot of Perl programming, and yet there are many Perl features
>> that I *never* find a use for, and I wonder whether this is because
>> these features are inherently not very useful, or it's me who is
>> being just too dense to realize what I'm missing.



There is another possibility:

or have you just not done a project that would have benefited
from the feature. (The "right tool for the job" thing.)


>> In decreasing
>> order "remoteness from everyday programming":
>>
>> 1. formats

>
> I actually used this once, but looking back at it, I should have
> just used printf.



That isn't enough if you need word-wrapping or page headers though.

So there are modules for getting that stuff.

I'd count this one as "never used". There are now better alternatives.

I seem to remember that they will not be in the core of Perl 6
either, which seems to reinforce that position.


>> 2. prototypes
>>
>> 3. operator overloading

>
> In fact, you're already using this; you just don't know it. Perl does a
> lot of behind-the-scenes stuff with overloading.



Right, but here we were talking "Perl programming" rather
than "perl programming".

That is, their usefulness at the Perl Program (programmer's API) level.

My take on the above 2:

Prototypes are a cure that can be worse than the disease, not used.

Operator overloading would most often introduce "startle factor",
so used only in very special circumstances, eg: when you are
implementing some domain-specific language in Perl.


>> 4. tied variables

>
> Now, this, on the other hand, is truly useful.



<aol> Me too! </aol>


--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas
 
Reply With Quote
 
kj
Guest
Posts: n/a
 
      03-13-2005
In <> Tad McClellan <> writes:

>Chris Mattern <> wrote:
>> kj wrote:
>>
>>>
>>> I do a lot of Perl programming, and yet there are many Perl features
>>> that I *never* find a use for, and I wonder whether this is because
>>> these features are inherently not very useful, or it's me who is
>>> being just too dense to realize what I'm missing.



>There is another possibility:


> or have you just not done a project that would have benefited
> from the feature. (The "right tool for the job" thing.)



>>> In decreasing
>>> order "remoteness from everyday programming":
>>>
>>> 1. formats

>>
>> I actually used this once, but looking back at it, I should have
>> just used printf.



>That isn't enough if you need word-wrapping or page headers though.


>So there are modules for getting that stuff.


>I'd count this one as "never used". There are now better alternatives.


>I seem to remember that they will not be in the core of Perl 6
>either, which seems to reinforce that position.



>>> 2. prototypes
>>>
>>> 3. operator overloading

>>
>> In fact, you're already using this; you just don't know it. Perl does a
>> lot of behind-the-scenes stuff with overloading.



>Right, but here we were talking "Perl programming" rather
>than "perl programming".


>That is, their usefulness at the Perl Program (programmer's API) level.


>My take on the above 2:


>Prototypes are a cure that can be worse than the disease, not used.


>Operator overloading would most often introduce "startle factor",
>so used only in very special circumstances, eg: when you are
>implementing some domain-specific language in Perl.



>>> 4. tied variables

>>
>> Now, this, on the other hand, is truly useful.



><aol> Me too! </aol>



Talk about startle factor, I'm kind of down on tied variables
because last week I spent a lot of time chasing a bug whose root
cause I'm sure is in some variable-tying nonsense in one of the
CPAN modules I was using (Filter::Util::Call). I didn't fully
track down the bug, but, in a nutshell, the act of assigning $_ to
a lexical variable would cause $_ to become undef. As in,

my $x;
$x = $_;
print "\$x: $x\n\$_: $_\n"; # *immediately* after the assignment,
# and in the same scope

=> $x: 1
$_:

Perl is tricky enough out of the box without any further attempts
at tie magic. These tied variables seem to sharply add to the
potential for befuddlement.

kj

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
 
Reply With Quote
 
Brian McCauley
Guest
Posts: n/a
 
      03-13-2005


kj wrote:

> I do a lot of Perl programming, and yet there are many Perl features
> that I *never* find a use for, and I wonder whether this is because
> these features are inherently not very useful, or it's me who is
> being just too dense to realize what I'm missing. In decreasing
> order "remoteness from everyday programming":
>
> 1. formats
>
> 2. prototypes
>
> 3. operator overloading
>
> 4. tied variables


I agree with the ordering. I never use formats. I almost never use
protypes.

Operating overloading and tied variables are handy when writing a module
that wants an elegant API. Since most prograqmming is either one side
or the other of an API it is true that actually implementing the API
itself is not an every-day task. I would however sorely miss these
features were they absent.

 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      03-13-2005
kj <> wrote:
> I do a lot of Perl programming, and yet there are many Perl features
> that I *never* find a use for, and I wonder whether this is because
> these features are inherently not very useful, or it's me who is
> being just too dense to realize what I'm missing. In decreasing
> order "remoteness from everyday programming":
>
> 1. formats


Never used them.

>
> 2. prototypes


Never define my own subs to use them, but I do benefit from subs from other
modules (e.g. List::Util) which do use prototypes.

> 3. operator overloading


I don't use them directly, but I think I do benefit from their use in
modules which I am never explicitly made aware of.

>
> 4. tied variables


I occasionally use this directly, like Tie::File and some hash cacheing
module I don't recall, but find them only marginally useful. I may benefit
more from using it indirectly without knowing it.


> I'm curious whether other Perl programmers find these feature
> useless as I do, and if not (as is likely) when do you find any of
> these features truly handy?


I've used tied variables to make large data structures more memory
efficient without having to recode the whole program.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
Big and Blue
Guest
Posts: n/a
 
      03-14-2005
kj wrote:

> I do a lot of Perl programming, and yet there are many Perl features
> that I *never* find a use for, and I wonder whether this is because
> these features are inherently not very useful, or it's me who is
> being just too dense to realize what I'm missing. In decreasing
> order "remoteness from everyday programming":
>
> 1. formats


I use this is some "quick-information" scripts to wrap output (*and* I
set the variable which determines where the long line may be split).

> 2. prototypes


Used to check that I use the function correctly within the same file.

> 3. operator overloading


Never used this directly.

> 4. tied variables


Used to dump the contents of dbm files (useful for NIS tools).
 
Reply With Quote
 
Jim Keenan
Guest
Posts: n/a
 
      03-14-2005
kj wrote:

> I do a lot of Perl programming, and yet there are many Perl features
> that I *never* find a use for, and I wonder whether this is because
> these features are inherently not very useful, or it's me who is
> being just too dense to realize what I'm missing. In decreasing
> order "remoteness from everyday programming":
>
> 1. formats


Used them in the first Perl program I ever wrote. Use the 'formline'
function which powers them a lot to this day.

>
> 2. prototypes


Never directly.

>
> 3. operator overloading


Never directly.

>
> 4. tied variables
>

Tie::File: every day. Lately some use of tied filehandles in testing
STDIN (a module I developed myself based on Camel book examples) and
STDOUT (IO::Capture::Stdout, IO::Capture::Stdout::Extended). But the
dirty details of tying are wrapped up inside these modules, so that I
don't have to think about them at the script-writing level.

Jim Keenan
 
Reply With Quote
 
phaylon
Guest
Posts: n/a
 
      03-14-2005
kj wrote:

> 1. formats


Nope.

> 2. prototypes


Jap, for any less-complex often-to-use functions.

> 3. operator overloading


Nope.

> 4. tied variables


Only for experimental/debugging. I always have this 'slow'-feeling when
I'm using them.

> I'm curious whether other Perl programmers find these feature useless as I
> do, and if not (as is likely) when do you find any of these features truly
> handy? I.e. what kind of programming task would become for you
> significantly more difficult (or plain less fun) to code if the feature
> were not available?


I would just say every coder has his own favorite "tools".


p

--
http://www.dunkelheit.at/
thou shallst fear...

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Too much spamming here to be of much use me thinks cpp4ever C++ 3 09-08-2009 02:08 PM
"I have been in several network marketing companies, but never have Iseen a system this impressive that does so much soquickly!" yuva Javascript 0 06-27-2008 09:56 AM
You have come? Definitely you have not gone shoplifes Python 0 11-25-2007 03:09 PM
You have come? Definitely you have not gone shoplifes Computer Support 0 11-25-2007 03:08 PM
have a look at my blog site for asp.net .. there is microsoft contest also ( u can win so much)have a look at my blog site for asp.net .. there is microsoft contest also ( u can win so much) justpratik Python 0 06-08-2007 04:48 AM



Advertisments