1. Re: EUPHORIA Digest - 21 Jun 1998 to 22 Jun 1998 (#1998-36)
- Posted by Andy Kurnia <akur at DELOS.COM> Jun 23, 1998
- 1332 views
At 12:00 AM 6/23/98 -0400, Automatic digest processor wrote: >Date: Mon, 22 Jun 1998 00:37:58 -0400 >From: Alan Tu <ATU5713 at COMPUSERVE.COM> >Subject: Untested File Size Function > >include file.e >global function file_size(sequence path) > integer file_i, seek_success > file_i =3D open(path, "rb) > seek_success =3D seek(file_i, -1) > return where(file_i) > close file_i >end function error 1: =3D --> this is because you enable "quoted printable" in your mailer. error 2: close file_i --> need (), so: close(file_i) error 3: return exits --> have to rephrase (otherwise file's not closed! you get only 12 files with Euphoria) read the previous digest, I have posted a supposedly-working function (for an "rb"-opened file) that does not change the file position. >Date: Mon, 22 Jun 1998 16:45:52 +1200 >From: "BABOR, JIRI" <J.Babor at GNS.CRI.NZ> >Subject: Re: ex bloatware > >Short-circuit evaluation is a very sensible optimization. ... Agreed!!!!! )) >Date: Mon, 22 Jun 1998 02:26:09 -0400 >From: Robert Craig <rds at EMAIL.MSN.COM> >Subject: Re: ex bloatware > >Actually, one of them belonged to you Actually, since you only found THREE programs, it wouldn't be hard to make the program run as intended with the short circuit function, again I suggest: a and b = (a * b) != 0 a or b = ((a != 0) + (b != 0)) != 0 it works with objects too!!!! >I'm going to take a harder look at this. I'm starting to think >that the implementation won't be that difficult. Also, >I could issue a warning in cases where old >code might break, i.e. where a function with >side-effects is called to the right of "and" or "or" >in a boolean expression. yay!! finally )) btw, how about the ?: operator? ppwsot? (pretty please with sugar on top) >Date: Mon, 22 Jun 1998 08:34:21 +0200 >From: Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL> >Subject: Short-circuiting > >Seeeee ??? > >-- This is short-circuited 3 -times >if 1 then if 1 then if 1 then > puts (1,"I'm in a short circuited if-statement, aint that nice ?\n") >end if end if end if that's "if 1 and 1 and 1 then", implemented in SEVEN statements. Aligned properly you get: if 1 then -- 1 if 1 then -- 2 if 1 then -- 3 puts(1, "xxx\n")-- 4 (replace your string here) end if -- 5 end if -- 6 end if -- 7 now let's talk about the clumsiness of "else" and short-circuited "or": include get.e object y constant x = {31,28,31,30,31,30,31,31,30,31,30,31} -- ignore leap -- x can be changed in the program e.g. to include Jupiter months while 1 do puts(1, "Enter a month with less than 31 days (0 to quit): ") y = get(0) if y[1] = GET_SUCCESS and not compare(y[2], 0) then puts(1, "Quitting.\n") exit elsif y[1] != GET_SUCCESS or not integer(y[2]) or y[2] < 1 or y[2] > length(x) or x[y] >= 31 then puts(1, "That is not a valid month!\n\n") else puts(1, "Thank you.\n") process(y[2]) end if end while Tell me how you would code the above if the "elsif" above with the current Euphoria version. Since I noted above x can be changed, you may not use elsif y[1] != GET_SUCCESS or not find(y[2], {2, 4, 6, 9, 11}) then which should work since get() always returns a 2-element sequence. Even better is to include a test if sequence(y) and length(y) = 2 and ..., but that isn't currently necessary. >Date: Mon, 22 Jun 1998 08:40:00 +0200 >From: Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL> >Subject: Re: Untested File Size Function > > The file size function a few people were requestion was regarding the >files they already opened. And then dos () will not return the right file >size. Euphoria cashes I/O for speed. dos()??? >Preciously, most things can be done through the use of routines. precisely: the point is preciously: expensively (?) >Date: Mon, 22 Jun 1998 02:40:41 -0400 >From: Karlheinz Nester <Karlheinz_Nester at COMPUSERVE.COM> >Subject: Help on converting to EUPHORIA > > printf(1," %-1s %5.2f",{m[z][con]),f[4]/1000}) (concat X1 and X2) ^ --> unexpected ')', expecting '}' delete the ) and it should run fine. (?) >Date: Mon, 22 Jun 1998 09:03:28 +0200 >From: Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL> >Subject: Re: Edom 2.02 > >I suppose Euphoria simply gets a lot slower handling a long sequence. eh? I hope that is not right!!! >Date: Mon, 22 Jun 1998 01:47:23 -0700 >From: Mathew Hounsell <mat.hounsell at MAILEXCITE.COM> >Subject: Euphorias File Limit :0 > >RDS if Euphoria can't open more then twelve files does that mean the >hightes file num is 14? I would like to know as then we can check if >it's we're about to run out of file numbers. Theoritically right, 0 = stdin, 1 = stdout, 2 = stderr, 3..14 = 12 files. I haven't tried it though. >Also the bug fixes could justify a Euphoria 2.0.1 release. Would be great with ?: and short-circuit and/or added. That bug fixes... what are they? message_box? ... >Date: Mon, 22 Jun 1998 06:23:57 -0400 >From: Alan Tu <ATU5713 at COMPUSERVE.COM> >Subject: Re: Untested File Size Function > >You just hit on an idea. However, upon cursory inspection, I found that >you would have to do more tinkering. Dir() returns a sequence of >sequences, and you'd have to find which file is the file you want. use dir("filename.ext") not dir("*.*") and you get only the file you want. >Date: Mon, 22 Jun 1998 08:38:49 -0400 >From: Irv <irv at ELLIJAY.COM> >Subject: Re: EUPHORIA Digest - 20 Jun 1998 to 21 Jun 1998 (#1998-35) > >I registered the original version 1.5. Routine_id() was necessary to implement >inheritance and other good stuff, so I downloaded the pd version 2.0. What is the value of compare( (price of registering 1.5) + (price to upgrade to 2.0 dos32 only), (price to just register 2.0 dos32 only) ) and compare( (price of registering 1.5) + (price to upgrade to 2.0 dual platform), (price to just register 2.0 dual platform) ) ? >> >2) Let a type function turn tracing on instead of return FALSE and make your >> >program crash like with an '300 statements limit' >> >> I don't understand this, Ralf, please explain. > >Oops! Ralf almost gave away the secret... I was expecting an explanation... private mail is OK >> I do that too , but most people I introduced it to has either a Perl >> background (in which case all of them rejects Euphoria, saying "Perl can >> already do lots of things, why bother?", to which I must agree), > >Aassembly language can do all those things and more. Why use Perl? Warning: Advertisement follows! <advertisement> Perl has flexilength sequences as well (though it's used differently), and it has built-in hashes, not to mention the always-necessary standard file-manipulation commands exist as built-in commands (unlink, mkdir, etc). Perl can read entire file at once, simply by undef $/; $x = <FILE>; while $x = <FILE> is normally translated to "x = gets(x)", and $/ is '\n'. That means we can define our own end-of-line string. Perl can do C-like commands like $i += 3; $j++; and has a non-block shape of control structure (saving an "end ..." from being counted by the 300 statement limiter) which works when you place the control statement at the end of the command, e.g. print "right!" if (3 < 5); Perl allows to modify file attributes and date/time with built-in commands. Perl allows assignments like ($a, $b, $c) = (3, 5, 2); # this means $a = 3; $b = 5; $c = 2; Perl allows command output capturing, as in $diffout = `diff -w oldfile newfile 2>&1`; # 2>&1 in unix means stderr should be redirected to stdout if ($? >> 8) { # if errorlevel is not zero print "Changes:\n"; print $diffout; } else { print "No changes\n"; } etc. Euphoria, stuck with the 20k tracer installed in it, can't do that... Perl can open as many files as your system allows. Euphoria limits you to only 12. Perl allows you to have a Perl code embedded as string, and execute it, and tell you if it worked or if it has an error. Codes are run in the current context, has access to the current variables, and can even define new subroutines. Euphoria has no self-embedding capability. Example: $x = 3; $y = "$x++;" eval $y; # not sure about the correct syntax though print $x; # displays 4 Perl can check if a variable or a routine exists, is defined, or ... well, Euphoria has routine_id but no variable_id. Finally, Perl is free (no download time) because it is included as a standard programming language in UNIX systems. Perl can also be compiled for win32 etc if you get the source, which is *available*. Euphoria limits you to 300 lines and never gives a public domain source where I can change that 300 ;-> </perladvertisement> There is no debugging facility at all in Perl (!), but I rarely use it if there were one. There is a great debugging facility in Euphoria, but with ugly colors. Euphoria will dump core, but not unless you are registered or your program is small -- and I do mean small. Why have I always asked for the 300 line limit to be removed? Because to me Euphoria is just a stripped-down Perl, since I rarely make small programs for that core dumper to work. >You might reply "why DIM? Aren't you dim enough already?".You might...but I >wouldn't recommend it. Hmm, nice pun , but they's not English speakers. >Or have paying programming jobs, either, I suspect.Putting BASIC on your resume >is good for laughs, but little else. >(Hey, we have all done it, but that doesn't mean we're proud of it!) >Date: Mon, 22 Jun 1998 10:29:25 -0400 >From: Arthur Adamson <euclid at ISOC.NET> >Subject: Re: Edom 2.02 > > Sorry for the error, change edo_save to edo_load. Thanks Andy for >catching it. Bye, Art You're welcome >Date: Mon, 22 Jun 1998 16:10:25 +0100 >From: "Carl R. White" <C.R.White at SCM.BRAD.AC.UK> >Subject: Re: atom() ambiguity > >On Fri, 19 Jun 1998, Daniel Berstein wrote: >> constant true=1 >> constant false=0 >> >> or type: >> >> type boolean (integer x) >> if x then -- If 'x' is != 0 >> return 1 >> else >> return 0 -- If x = 0 >> end type > >This code won't work. A program would crash if it a boolean was set to >false(0) and wouldn't crash if x = 7 (for instance). That's the *second* error I'd point out, after complaining about no "end if" statement. >type boolean(object x) > if not integer(x) then > return TypeFail > end if > return x=not(not x) >end type Right, except I'd write "x = not(not x)" as "x = (x != 0)". Note how the four statements inside type..end type would be condensed to a mere ONE if we had a selective ternary conditional operator (in C it's called ?:): return integer(x) ? (x = (x != 0)) : 0 A short-circuit boolean would be just as handy here: return integer(x) and (x = (x != 0)) -- assuming and is short-circuit but lacks the flexibility given by ?: in some cases. >Date: Mon, 22 Jun 1998 12:26:24 -0300 >From: Daniel Berstein <daber at PAIR.COM> >Subject: Re: EUPHORIA Digest - 20 Jun 1998 to 21 Jun 1998 (#1998-35) > >To my knowledge: Any Euphoria programmer is eligible for the Euphoria >Economy promotion, but only registered users votes are counted. Great! Thanks, I'll think of something I can do to get some votes >Date: Mon, 22 Jun 1998 12:58:29 -0300 >From: Daniel Berstein <daber at PAIR.COM> >Subject: Re: atom() ambiguity > >Quite right Carl... Mea Culpa ;) Define mea culpa. >Does it work? If x=False (0) then: ^^^^^^^^^^^ read that line > return x=not(not x) > return x=not(1) > return x=0 --->False ... and since x = 0 above we get: return 0=0 return 1 --> TRUE )) [the --> works nicely as a comment since comments start with -- ] >The type declaration should be: ... > for i=1 to length(x)-1 do > t = boolean(x[i]) and boolean(x[i+1]) > end for WRONG! it will only evaluate if the last 2 elements are both booleans... Should be t = 1 for i = 1 to length(x) do t = t and boolean(x[i]) end for ... and since you consider boolean(atom x) is 1, and boolean(sequence x) evaluates to the calculation of boolean(atom x) and boolean(atom x) somehow, boolean(object x) never returns 0 (well, except if there is an empty sequence that is considered) btw I don't think that's the correct definition of boolean... well, boolean is true or false only, each having one representing value. Not "all nonzeroes are true". It will work with inputs though... >Date: Mon, 22 Jun 1998 12:45:48 -0500 >From: Terry Constant <constant at FLASH.NET> >Subject: Re: shrouding > >A binded (bound?) file simply attaches shrouded/compiled code to the exe Yes, I think it's "bound" not binded. >Date: Mon, 22 Jun 1998 13:44:34 -0300 >From: Daniel Berstein <daber at PAIR.COM> >Subject: Re: shrouding > >of a copy of ex.exe. Bounded programs are by default shrouded also, so no >one can mess with the embbeded code in the executable. By default??? Can one have an UNshrouded program bound, and e.g. have it self-modify upon running? >Date: Mon, 22 Jun 1998 13:57:44 CDT >From: Lewis Townsend <keroltarr at HOTMAIL.COM> >Subject: Re: Mouse_Zipped > >Also these *.exe files are NOT executable, I always have to rename them >to use them. This is not a big deal but if you can fix it, I, for one, If you don't want to rename them then try: pkunzip mouse~1.exe (the short file name of mouse.zip.exe) end if >Date: Mon, 22 Jun 1998 15:22:02 -0400 >From: Robert Craig <rds at EMAIL.MSN.COM> >Subject: Re: EUPHORIA Digest - 20 Jun 1998 to 21 Jun 1998 (#1998-35) > >Andy Kurnia writes: >> Does that offer apply to non-registered Euphoria programmers? > >Yes it does. Any file on the RDS site can receive Thanks ) >Date: Mon, 22 Jun 1998 15:12:54 -0400 >From: Robert Craig <rds at EMAIL.MSN.COM> >Subject: Re: Euphorias File Limit :0 > >Anyway, it will be higher in the next release. hopefully *really* higher, not just changing 0..14 to 0..15 btw: is the limit <= 300 statements or < 300 statements??? >Date: Mon, 22 Jun 1998 16:34:32 -0400 >From: Robert B Pilkington <bpilkington at JUNO.COM> >Subject: Re: Short-circuiting > >Hey, I type at 80 words per minute..... I'm not worried about extra >typing.. :) (Well, that's my adjusted words per minute.. after errors... >I make quite a few..) Besides, if you're using variable names that are >too long, then you should shorten them. Even if you just assign it to >"object junk" before you do some ifs so you don't have to type it 3 >times, fine... :) I type quickly and still want to have short-circuit... nice object junk idea, if only I didn't have to try cutting my program to less than 300 statements. >Date: Mon, 22 Jun 1998 21:04:40 EDT >From: Lmailles at AOL.COM >Subject: Re: Short Circuiting > >If you wish to do short-circuiting for error-avoiding purposes I (again) agree >with Ralf : > >use > >if then if then if then >end if end if end if uuuuggggllllyyyy >Date: Mon, 22 Jun 1998 22:45:28 -0400 >From: Alan Tu <ATU5713 at COMPUSERVE.COM> >Subject: Has anyone written a hash function? > >Has anyone written a function that hashes someone into a checksum? hashes *someone*!?!?!?