Re: See Vs. See

new topic     » goto parent     » topic index » view thread      » older message » newer message

BTW, I cheated in that I hand-edited the output a bit
to hide my crappy coding style :p

Mike The Spike

--- Mike The Spike <mtsreborn at yahoo.com> wrote:
> See?
> 
> Who ever said MTS was an ass? (you awnser than and
> I'll break your face)
> 
> It seems that we are on the same level, Robert and
> me.
> 
> I like what the new translator produced, but it's
> still 
> not *all that*.
> 
> Let me show you a simple program translated to C
> using
> my old U4IA++ To C Translator;
> 
> --------------Euphoria Version--------------------
> 	--------------------------------
> 	-- A very simple sort program --
> 	--------------------------------
> function simple_sort(sequence x)
> object temp 
>     for i = 1 to length(x) - 1 do
> 	for j = i + 1 to length(x) do
> 	    if compare(x[j],x[i]) < 0 then
> 		temp = x[j]
> 		x[j] = x[i]
> 		x[i] = temp
> 	    end if
> 	end for
>     end for
>     return x
> end function
> 
> -- Hold down the Enter key and 
> -- watch x get sorted before your eyes! 
> ? simple_sort( {9, 10, 3, 1, 4, 5, 8, 7, 6, 2} )
> ---------------Above Translated To C Using
> Bind.exe---
> 
> /* This Program Was Generated By U4IA++      */
> /* It By No Means Promotes Good Coding Style */
> 
> /* U4IA++ By Mike The Spike */
> 
> 
> /* simle.ex */
> 
> /* Standard Include Files */
> #include "Euphoria.h"
> 
> object simple_sort(sequence x)
> {
>     object temp;
>     for(i = 0; i < x.length; i++)
>     {
>         for(ix = i + 1; ix < x.length; ix++)
>         {
>               if(compare(x.data[ix],x.data[i]) < 0){
>                   temp = new_object(x.data[ix]);
>                   x.data[ix] = x.data[i];
>                   x.data[i] = temp;
>               }
>         }
>     }
> return x;
> }
> 
> int main()
> {
>      sequence u4ia_01;
>      u4ia_01 = new_sequence(10);
>      u4ia_01.data[0] = new_atom(9);
>      u4ia_01.data[1] = new_atom(10);
>      u4ia_01.data[2] = new_atom(3);
>      u4ia_01.data[3] = new_atom(1);
>      u4ia_01.data[4] = new_atom(4);
>      u4ia_01.data[5] = new_atom(5);
>      u4ia_01.data[6] = new_atom(8);
>      u4ia_01.data[7] = new_atom(7);
>      u4ia_01.data[8] = new_atom(6);
>      u4ia_01.data[9] = new_atom(2);
> 
>      u4ia_print(simple_sort(u4ia_01);
> 
> free(u4ia_01.data);
> return 0;
> }
> 
> 
> 
> That's it.
> 
> Now I'm not saying you should try to clone my own
> translator, (hell no! It's got more bugs than
> Windows!), but atleast try to aproximate it's
> simplicity.
> 
> My goal was to produce fast, readable C programs
> from
> Euphoria programs.
> My goal was not to produce C programs that 'work
> just
> like' the input Euphoria program.
> 
> And if you play it smart, like I did with typedef'ed
> Euphoria datatypes, you don't have to ref and deref
> all the time.
> Who cares?
> In my U4IA++, a sequence is an array of objects,
> wich
> are in place datatypes wich can take any size and
> format, even other sequences.
> When you don't use a sequence anymore, free() the
> array and use the space freed again somewhere else.
> 
> I still believe we should be able to opt for a
> non-garbage colected source file.
> I mean, deallocating a single atom is just asking
> for
> lag.
> 
> Aslong as the memory is freed at the end of the
> program, so no memory leaks are present, we'll
> manage
> without having garbage collected atoms.
> Especially when we build-up character strings
> dynamically, we don't want Euphoria to derefference
> each character for us.
> 
> 
> Mike The Spike
> 
> --- Robert Craig <rds at RapidEuphoria.com> wrote:
> > MTS writes:
> > > -----------A Simple Math Demo In C----------
> > 
> > Your alpha translator produced 176 (non-blank)
> lines
> > of C.
> > The new beta translator (due in a week or so)
> > produces
> > just 66 lines of C for the same example.
> > Here they are:
> > 
> > void main(int argc, char *argv[])
> > {
> >     int _12 = 0;
> >     int _17 = 0;
> >     int _0, _1, _2, _3;
> >     Argc = argc;
> >     Argv = argv;
> >     eu_startup(_00, 1, (int)CLOCKS_PER_SEC,
> > (int)CLK_TCK);
> >     init_literal();
> >     shift_args(argc, argv);
> >     _0a = 50;
> >     _0b = 60;
> >     _12 = 120;
> >     _0c = 119;
> >     _12 = 110;
> >     _17 = 476;
> >     if (476 & 1) {
> >          _17 = NewDouble((476 >> 1) + 0.5);
> >     }
> >     else
> >         _17 = 476 >> 1;
> >     if (IS_ATOM_INT(_17)) {
> >         _0d = 110 + _17;
> >     }
> >     else {
> >         _0d = NewDouble((double)110 +
> > DBL_PTR(_17)->dbl);
> >     }
> >     if (!IS_ATOM_INT(_0d)) {
> >       _1 = (long)(DBL_PTR(_0d)->dbl);
> >        DeRefDS(_0d);
> >       _0d = _1;
> >     }
> >     RefDS(_20);
> >     DeRef(_0fa);
> >     _0fa = _20;
> >     DeRef(_0fb);
> >     _0fb = NewDouble(DBL_PTR(_0fa)->dbl +
> > DBL_PTR(_0fa)->dbl);
> >     DeRef(_17);
> >     _17 = NewDouble(DBL_PTR(_0fb)->dbl /
> > DBL_PTR(_22)->dbl);
> >     DeRef(_0fc);
> >     _0fc = NewDouble(DBL_PTR(_0fa)->dbl +
> > DBL_PTR(_17)->dbl);
> >     DeRefDS(_17);
> >     _17 = NewDouble(DBL_PTR(_0fa)->dbl *
> > DBL_PTR(_0fb)->dbl);
> >     _12 = NewDouble(DBL_PTR(_0fc)->dbl *
> > DBL_PTR(_26)->dbl);
> >     DeRef(_0fd);
> >     _0fd = NewDouble(DBL_PTR(_17)->dbl +
> > DBL_PTR(_12)->dbl);
> >     _0 = _12;
> >     _1 = NewS1(8);
> 
=== message truncated ===

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu