I am puzzled why you seem to have a disgust for OOP, Nemo.

Bud

On Tue, Apr 21, 2009 at 12:20 PM, Nemo Nihil <[email protected]> wrote:

> Rob Ludwick wrote:
>
>> Give me a more politically correct term then. I just chose 'fringe' for
>>> lack of more descriptive terms.
>>>
>>
>> I like using the term "Python" for describing Python.  ;)
>>
>
> I actually like calling it 'not listed as a requirement by many employers'.
> That's really the main part of my argument, too. In my last search for
> software engineering positions I saw the following languages repeated over
> and over (roughly in order from most requested to least): Java, C/C++
> (listed together), PHP & javascript (usually listed together), perl, ADA
>
> Not a single mention of python, tcl, or ruby, though those seem fairly
> common in the freelance open source community. Sadly, since the industry
> seems to want people proficient in java more than anything, I'm probably
> going to have to learn it eventually, even though I find the thought of OOP
> everywhere extremely repulsive.
>
>
>
>> So here's what I'm proposing.  Since you dislike python's use of
>> whitespace, I will write a python braceificator and we can compare and
>> contrast.
>>
>> And here it is.  I wouldn't use the term "Beautiful" to describe this
>> piece of code.  I prefer "Pragmatic".  If it happens to look beautiful,
>> that's merely a side effect.
>>
>> def indentlevel(line):
>>    count = 0
>>    while len(line) and line[0] == " ":
>>        line=line[1:]
>>        count +=1
>>
>>    return count
>>
>> def bracify(file):
>>    infd = open(file,"r")
>>    outfd = open(file+".by","w")
>>
>>    bracelevel = [0]
>>
>>    originalline = " "
>>    while originalline != '':
>>                originalline=infd.readline()
>>        line = originalline.rstrip()
>>        level = indentlevel(line)
>>
>>        if line.lstrip() == "":
>>            outfd.write(line + "\n")
>>            continue
>>
>>        if level > bracelevel[-1]:
>>            outfd.write(level * " " + "{\n")
>>            bracelevel.append(level)
>>
>>        while bracelevel[-1] > level:
>>            outfd.write(bracelevel.pop() * " " + "}\n")
>>
>>        if line[-1] == ":":
>>            outfd.write(line + "\n")
>>            continue
>>
>>        while line[-1] == '\\':
>>            outfd.write(line)
>>            line = infd.readline().rstrip()
>>
>>        outfd.write(line + ';\n')
>>
>>    while len(bracelevel):
>>        outfd.write(bracelevel.pop() * " " + "}\n")
>>
>>
>>
>> And here is what the braceified version of the same code looks like:
>>
>> def indentlevel(line):
>>    {
>>    count = 0;
>>    while len(line) and line[0] == " ":
>>        {
>>        line=line[1:];
>>        count +=1;
>>
>>        }
>>    return count;
>>
>>    }
>> def bracified(file):
>>    {
>>    infd = open(file,"r");
>>    outfd = open(file+".by","w");
>>
>>    bracelevel = [0];
>>
>>    originalline = " ";
>>    while originalline != '':
>>
>>        {
>> ....
>>
>> Anyway you get the point.
>>
>
> I'd be more impressed if you hacked out something that turned it into
> complete C  code (minus low-level variable stuff, of course) ;)
>
> You used OOP crap in there too, by the way...yuck. Really should only need
> to use that for GUI-level stuff.
>
>
>> At this point it seems pretty trivial to write a debraceificator to
>> convert it back to normal python syntax.  Replace the semicolons with
>> linefeeds and count braces for indentation.  And then you would have
>> something that with a little polish would replace whitespace with
>> braces.
>> Oh and the code ports easily to jave:
>>
>> $jythonc -j braceificator.jar braceificator.py
>>
>
> Yuck.
>
>
>
>> --R
>>
>>
>> _______________________________________________
>> Fwlug mailing list
>> [email protected]
>> http://fortwaynelug.org/mailman/listinfo/fwlug_fortwaynelug.org
>>
>
>
>
> _______________________________________________
> Fwlug mailing list
> [email protected]
> http://fortwaynelug.org/mailman/listinfo/fwlug_fortwaynelug.org
>
_______________________________________________
Fwlug mailing list
[email protected]
http://fortwaynelug.org/mailman/listinfo/fwlug_fortwaynelug.org

Reply via email to