Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

MySQL protocol bug

 [1/8] from: maarten:vrijheid at: 19-Feb-2004 11:25


Very Good! Now Doc has a bugfix and he can make it a 1.0 release ;-) --Maarten Hallvard Ystad wrote:

 [2/8] from: dockimbel:free at: 19-Feb-2004 11:50


Hi, Sorry for this annoying little bug. You can fix it easily by adding s: none in the main context, just after the following comment : ;------ Data reading ------ BTW, it's funny to see how our personal coding style can evolve. While looking at the piece of code you've exposed to show the problem, I was thinking how would I wrote that today. In case, this can be useful for someone : Old code: read-field: [ (null-flag: false) read-length s: (either null-flag [field: none] [field: sys-copy/part s len s: skip s len]) :s ] New code (how I would write it today): read-field: [ (null-flag: false) read-length copy field len skip (if null-flag [field: none]) ] It's untested, but looks much better, don't you think ? :-) -DocKimbel. Hallvard Ystad wrote:

 [3/8] from: maximo:meteorstudios at: 19-Feb-2004 9:33


> -----Original Message----- > From: Nenad Rakocevic [mailto:[dockimbel--free--fr]]
<<quoted lines omitted: 6>>
> problem, I was > thinking how would I wrote that today.
I find this to be more true in rebol than in any other language I've used. I guess its because rebol, being only expressions, can express the same problem differently. Much like any standard math algebra. 1 + 2 = 3 = 4 - 1 = 6 / 2 when using structured languages, they define how the language understands any given concept and it is your problem to adapt your code to that -syntax- or grammar. for example: in python if you want to create a function you MUST use: def funcname (arg): put your code here in rebol, creating a function is an expression! so you usually write:
> funcname: func [arg] [put your code here]
not everyone realizes that you ASSIGN a value to a word (~variable). In the same manner that you use any other function. A value is calculated by the 'func function (which creates a new function VALUE). but you can also do:
> arglist: [arg] > code-block: [put your code here] > funcname: func arglist code-block
or
> funcname: func append arglist 'arg2 append code-block [print arg2]
hey, thats polymorphism without even having an object! Now, how many languages will handle a stray value in code without choking... not even python will let you insert a string anywhere in its code, if its not being used by a function. Because rebol really is just evaluating expressions as it encouters them one thing at a time, when it hits a string value, for example, IF no previous function required an argument, it is ignored, and evaluation simply continues to the following item of code. python or c would give you a syntax error, because it excepts ALL values to be part of a structure, which is defined by strict syntax and parenthesis useage. When it encouters bogus data, it just cant handle it, cause it differentiates values and functions. IMHO rebol does not. They really are all just values, even functions. I know this is isn't news to any of the fluent rebolers, but once and a while I like to remind the list about these potent rebol features for newcommers. There are many other hidden features which rely on the fact that rebol's syntax is really just concerned with expressions, and with the fact that code IS data, until the exact moment it is evaluated. As all the "modern" language get closer and closer to supporting many of the same features (garbage collecting, objects, dynamic name resolution, etc), I find that rebol, by its expressive nature, stands out. Though, being alone in the dark isn't quite good either. Some MAJOR enterprise or software has to embrace rebol, to let others loose skepticism... and I can't see that happening yet! Whatever happened to the old morpheus deal... -MAx

 [4/8] from: joel::neely::fedex::com at: 19-Feb-2004 10:34


Hi, Maxim, Pardon my being picky, but we can take your point even further... Maxim Olivier-Adlhoch wrote:
> in rebol, creating a function is an expression! so you usually write: > >>funcname: func [arg] [put your code here] >
Although we *may* write something like that, when we do so we are actually combining two distinct concepts in one expression: 1) defining a function, and 2) making a particular word refer to that function. and the habit of thinking of those two together results in one of the standard newbie questions: "How can I find out the name of this function?" which is no more meaninful than asking for "the name" of a value of any other type. (Of course, that's what it means to say that functions are first-class values...) "How can I find out the name of 2?" "How can I find out the name of {Hello, world!}?" etc.
> Now, how many languages will handle a stray value in code > without choking... not even python will let you insert a
<<quoted lines omitted: 7>>
> values and functions. IMHO rebol does not. They really are > all just values, even functions.
The following (console transcript) shows that one *can* insert values (e.g. strings) into the body of a Python function when such values aren't actually used for anything.
>>> def somefunc (x, y):
.... """silly function containing pointless string""" .... x2 = x * x; .... y2 = y * y; .... "foo?"; .... print x2 + y2; ....
>>> somefunc (3, 4)
25 One can do similar things in Perl. The parser will let you know that the value is not used; surely you don't think that's all bad??? How many of us have *never* made a typo in a REBOL script that changed the meaning of something in a way that produced an error, but the interpreter never helped us find it? (However, Perl will still run your program after whining at you.) For example, take a largish REBOL script and delete a single occurrence of '+ somewhere in the middle. -- ---------------------------------------------------------------------- Joel Neely joelDOTneelyATfedexDOTcom 901-263-4446 Enron Accountingg in a Nutshell: 1c=$0.01=($0.10)**2=(10c)**2=100c=$1

 [5/8] from: maximo:meteorstudios at: 19-Feb-2004 12:35


Hi Joel,
> Pardon my being picky, but we can take your point even > further...
please do!
> Maxim Olivier-Adlhoch wrote: > > Although we *may* write something like that, when we do so > we are actually combining two distinct concepts in one > expression: > > 1) defining a function, and > 2) making a particular word refer to that function.
Which is why we can easily define and create nameless functions on the fly (in other languages too) but how natural is it in other languages. not very. func [arg][print "hello"] is legal in rebol def (arg): print "hello" makes no sense in python, cause you've got a specific SYNTAX for creating functions. yet in rebol, as long as you follow the argument count of ANY function (like 'func or 'print), you're all set. which was my original point. Although, you can eval() code in python, its much less "natural" and friendly than in rebol. Also, rebol handles contexts with much more flexibility (read as head aches, until you understand ;-). I'd like people with experience in scheme or ruby to butt in! I'd like to see how rebol stands out compared to them.
> and the habit of thinking of those two together results in > one of the standard newbie questions:
<<quoted lines omitted: 4>>
> "How can I find out the name of 2?" > "How can I find out the name of {Hello, world!}?"
yep!!! nice illustration
> > Now, how many languages will handle a stray value in code > > without choking... not even python will let you insert a > > string anywhere in its code, if its not being used by a > > function.
should have read: "not even python will let you insert a VALUE OF RANDOM TYPE anywhere in its code" just tested with an integer and python chokes. rebol just goes... but a warning (which could be disabled) could be usefull... I know rebol will choke with a random WORD type, but that's because the interpreter evaluates words specifically... so they SHOULD have a meaning.
> > ... > > python or c would give you a syntax error, because it excepts
<<quoted lines omitted: 7>>
> values (e.g. strings) into the body of a Python function when > such values aren't actually used for anything.
read above, won't work with (m)any other type(s)...
> One can do similar things in Perl. The parser will let > you know that the value is not used; surely you don't think > that's all bad???
no, that's a good thing (the warning).
> How many of us have *never* made a typo > in a REBOL script that changed the meaning of something in > a way that produced an error, but the interpreter never > helped us find it?
count: None
> For example, take a largish REBOL script and delete a single > occurrence of '+ somewhere in the middle.
even better, just remove a random SPACE in any expression which sends data to another function! like (1 + 1) vs. (1 +1) I wish rebol could at least tell you in which SCRIPT FILE a crash occurs! when I do large apps which include several files and total code size exceeds 100k (or more), then a random error becomes a random attempt at solving it (generally including 'print until you track the grevious line). This is especially bad when the error comes from a native or a mesanine to which you've supplied erronous data. This is probably my pet peave about rebol <Sigh>... error tracing is very hard to do in an environment which promotes self-modifying code. It could be better if rebol had some kind of stack trace... maybe we could patch (encompass) 'func do to just that... <hummm> -MAx

 [6/8] from: hallvard:ystad:oops-as:no at: 19-Feb-2004 19:52


Dixit Maxim Olivier-Adlhoch (15.33 19.02.2004):
>Because rebol really is just evaluating expressions as it encouters them one thing at a time, when it hits a string value, for example, IF no previous function required an argument, it is ignored, and evaluation simply continues to the following item of code.
Correction: the string is not ignored. It is evaluated (to itself!). Isn't it so?
>I know this is isn't news to any of the fluent rebolers, but once and a while I like to remind the list about these potent rebol features for newcommers.
You're right to do so. Although I've been a rebol script kiddie for a long time, I don't think I realized this (about the Expression Based part of REBOL) before the third or fourth time I read these things.
>Whatever happened to the old morpheus deal...
Yes, we were promised to have our socks blown off! So, ... ? HY

 [7/8] from: joel:neely:fedex at: 19-Feb-2004 13:32


Hi, again, Maxim, Maxim Olivier-Adlhoch wrote:
> Which is why we can easily define and create nameless functions > on the fly (in other languages too) but how natural is it in > other languages. not very. >
....
> I'd like people with experience in scheme or ruby to butt in! > I'd like to see how rebol stands out compared to them. >
To quote from _The_Scheme_Programming_Language_, Third Edition by R. Kent Dybvig (2003, MIT Press): The general form of a lambda expression is (lambda (var ...) exp1 exp2 ...) The variables var ... are the formal parameters of the procedure, and the sequence of expressions exp1 exp2 ... is its body. ... A procedure is just as much an object as a number, string, symbol, or pair. with almost complete parallelism to REBOL's 'func behavior. WRT Ruby, a "block" can be thought of as an anonymous function. An example from _Programming_Ruby_-_The_Pragmatic_Programmer's_Guide_ by Dave Thomas and Andy Hunt (2001, Addison Wesley Longman, Inc.) illustrates the syntax. The expression @songs.find { |aSong| key == aSong.name } supplies a block with one parameter to the "find" method of Array. (The variable "key" is from the immediately-surrounding context.) The nearest REBOL equivalent for that line I can think up quickly would use an equivalent to Ruby's built-in "find": find-if: func [s [series!] f [any-function!]] [ foreach item s [ if f item [return item] ] ] If SONGS is a block of blocks [ [name artist duration] ... ] such as [["Proud Mary" "CCR" 4:30] ["Silk Road Suite" "Kitaro" 65:25] ...] and then express the above Ruby code with something resembling find-if songs func [aSong] [key = aSong/1] so (after we define all the supporting machinery) there's not a great deal of difference in typing effort.
>> >> > without choking... not even python will let you insert a
<<quoted lines omitted: 3>>
> VALUE OF RANDOM TYPE anywhere in its code" > just tested with an integer and python chokes.
I just tested with an integer and Python wasn't bothered at all:
>>> def somefunc (x, y):
... """another, even sillier function""" ... x2 = x * x; ... y2 = y * y; ... 13; ... print x2 + y2; ...
>>> somefunc (3, 4)
25 Note the gratuitious insertion of 13...
> I wish rebol could at least tell you in which SCRIPT FILE > a crash occurs! >
I must admit I still don't know what that means. Consider the following case: File a.r contains wordlist: [a b d] File b.r contains exprlist: [a + b / c] File c.r contains container: reduce [ func replace/all wordlist 'd 'c replace/all exprlist 'd 'c ] File d.r contains test: func [x] [container/1 1 3 x] and the user types test 0 which, when evaluated, produces ** Math Error: Attempt to divide by zero ** Where: 1 ** Near: a + b / c Now, I really don't know how to answer the question "Which script file did the error occur in?" Can you enlighten me? -jn- -- Joel Neely com dot fedex at neely dot joel I had proved the hypothesis with a lovely Gedankenexperiment, but my brain was too small to contain it. -- Language Hat

 [8/8] from: joel:neely:fedex at: 19-Feb-2004 14:01


Hi, yet again, Maxim, I forgot one detail in my prior response... I meant to include this when I addressed the Scheme and Ruby variations, but forgot about it by the time I had finished those. -jn- Maxim Olivier-Adlhoch wrote:
> I'd like people with experience in scheme or ruby to butt in! > I'd like to see how rebol stands out compared to them. >
At the risk of horrifying people by using the "P" word, Perl also has simple syntax for such things: sub bletch { ...expressions go here... } creates a subroutine/function named "bletch", while sub { ...expressions go here... } creates something that could be thought of as an "anonymous subroutine" (actually a "code reference" but the terminology isn't the critical issue at this point). -- ---------------------------------------------------------------------- Joel Neely joelDOTneelyATfedexDOTcom 901-263-4446 Enron Accountingg in a Nutshell: 1c=$0.01=($0.10)**2=(10c)**2=100c=$1

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted