Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

rambling (deux)

by ar0n (Priest)
on Jun 10, 2000 at 01:57 UTC ( #17450=monkdiscuss: print w/replies, xml ) Need Help??

two ideas i happened to stumble upon while
dev-nulling my stuff in my room.
(if that doesn't make sense to you, i know how you feel)

Line numbering (two options)
  • Option in user settings that'll display line numbers before each line of code
  • option to specify with a <code> tag, i.e: <code ln="on">

syntax highlighting
option in user settings that'll turn on or off syntax highlighting.
not for me, but for people *really* new to Perl.
would spoil the fun of obfuscated code though ;-)

Replies are listed 'Best First'.
RE: rambling (deux)
by Corion (Patriarch) on Jun 10, 2000 at 14:45 UTC

    I don't think we need line numbering. In the Code catacombs, there already is automatic line numbering, and for the rest of the sections, automatic line numbering would be confusing since there is no way to reference line numbers from the text. Two examples :

    Here we have the trivial hello world program :

    1: #!/usr/bin/perl -w 2: print "Hello World\n"; 3: exit 0;
    And here we have another way to do it :
    4: #!/usr/bin/perl -w 5: print << X 6: Hello World 7: X

    In the above case, restarting line numbering would have been the right thing, as the above code are really two programs. But always restarting line numbering is also a bad idea :

    First, we need to include some modules and pseudo-modules :

    1: use strict; 2: use warnings; 3: use IO::Socket;
    and now we need to predeclare some variables and initialize our defaults :
    1: my $port, $host; 2: $host = shift || "localhost"; 3: $port = shift || 8000;
    Here, it would be better to have the line numbers continue.

    As for the syntax highlighting, currently the <CODE>-tags are used for almost all preformatted stuff, also for HTML stuff etc., but maybe it would be interesting to have syntax highlighting. But from what I see, syntax highlighting is far from trivial, since you will more or less need a Perl parser for that, as Perl cannot be parsed by line or by keywords, and strings have at least three different possibilitie

      oops, i guess i should read a little more! thanks :-)
(bbfu) Re: rambling (deux)
by bbfu (Curate) on Mar 23, 2001 at 09:27 UTC

    Firstly, forgive that I'm such a late-commer to this thread, but I just found it (thanks to turnstep's home-node).

    I would like to say that I think that optional line-numbered <CODE> tags is a good idea. One way to implement it would be to allow an attribute to the existing tag, the value of which would be used to determine where to start counting. Ie, if you use the same value as a previous <code> tag (in the same node, of course) the #'s would continue. They wouldn't if you used a new value.

    I would also like to refute Corion's assertation that syntax highlighting is hard. If I can do it, there are plenty of people here that could do it better (well enough to be used on the site, I'm sure). I think, though, that if it were added as an option, it would need to be used sparingly. Perhaps limited to certain sections, or at least defaulted to "off". Otherwise it might put an undue strain on the PM server (that depends, of course, on how efficient of an implementation was used).

    Anyway, that's my belated ${2/100}. Hope someone sees this....... ;-)

    Seasons don't fear The Reaper.
    Nor do the wind, the sun, and the rain.
    We can be like they are.

RE: rambling (deux)
by Adam (Vicar) on Jun 10, 2000 at 23:02 UTC
    I would agree with Corion on all points, except one. I think that having a second <code> tag that added line numbers would be a good thing. I wouldn't worry too much about when to restart numbering... you should always start from 1 (or 0) and if you want to embed comments, then use actual comments. Not a big deal.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: monkdiscuss [id://17450]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2022-12-09 06:58 GMT
Find Nodes?
    Voting Booth?

    No recent polls found