• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r4wp

[!REBOL3] General discussion about REBOL 3

GrahamC
27-May-2013
[2476]
yes
MaxV
27-May-2013
[2477]
Can you explai what the follwing function do?
http://rebol.informe.com/forum/rebol-3-f9/what-does-it-t65.html
GrahamC
27-May-2013
[2478]
Invisible
Arnold
27-May-2013
[2479]
http://rebol.informe.com/forum/rebol-3-f9/what-does-it-t65.html
Cyphre
27-May-2013
[2480]
that function just converts a string (rebol script/code) into :C 
encoded string".  Such C-strings are then used usually at R3 boot 
time to execute all the interpreter system or host code etc.
Arie
28-May-2013
[2481]
Hi, i'm at the beginning of a project in which i need access to a 
remote MySQL db. 

I tried Softinnov's MySQL driver, but that seems to be outdated (MySQL 
complains about client protocol).
Does anyone know an up-to-date MySQL driver for Rebol (2 or 3)?
Pekr
28-May-2013
[2482x2]
hmm, maybe R3 plus ODBC extension?
but that's most probably for Windows ...
james_nak
28-May-2013
[2484]
@arie, what version of the MySQL driver are you using?
Maxim
28-May-2013
[2485]
and what version of mysql?
Arie
28-May-2013
[2486]
@james_nak 1.2.1 from 12/07/2008
DocKimbel
28-May-2013
[2487]
Arie, try with http://softinnov.org/tmp/mysql-protocol-41.r
Arie
28-May-2013
[2488x2]
@Maxim 5.5.31 protocol version 10
@DocKimbel i'll try ...
Maxim
28-May-2013
[2490x2]
latest drivers should work with 5.5  IIRC
I'm definitely using v5.5.31 on windows with R2 v2.7.8.  (just checked).


 pretty sure Quarter Master uses Doc's drivers (which is what is setup 
 for mysql right now), though I may be wrong.
Arie
28-May-2013
[2492]
@DocKimbel that works; hurray!

I guess that the documentation on Softinnov's site is still appropriate?
DocKimbel
28-May-2013
[2493]
Yes, the documentation is still up to date.
Arie
28-May-2013
[2494]
Thank you very much :-))
DocKimbel
28-May-2013
[2495]
You're welcome. :)
Geomol
29-May-2013
[2496x5]
Continuing from #Red group. A johnk asked for multi-line source from 
Carl. This is my W_GETS code in World, which has multi-line (blocks 
and long strings). I don't know, if you can use it, as World might 
be different internal:

char prompt_str[]	= "prin system/console/prompt";
char block_str[]	= "prin system/console/block";
char string_str[]	= "prin system/console/string";

#define W_GETS \
	if (W->line_read) { \
		free (W->line_read); \
		W->line_read = NULL; \
	} \
	if (W->top_of_series > W->series_base) { \
		W->stack = W->stack + 1; \
		int trace = W->trace; \
		W->trace = 0; \
		if (*W->top_of_series == BLOCK_BEGIN_T) { \
			tv.newline = 1; \
			do_string (W, block_str); \
			int i; \
			for (i = 0; i < W->top_of_blocks - W->blocks; i++) \
				w_printf ("    "); \
		} else { \
			do_string (W, string_str); \
			w_printf ("    "); \
		} \
		W->trace = trace; \
		W->stack = W->stack - 1; \
	} else { \
		W->top_of_code = W->code - 1; \
		W->top = -1; \
		if (NULL != W->P) \
			printf ("**** W->P != NULL ****\n"); \
		W->stack = W->stack + 1; \
		int trace = W->trace; \
		W->trace = 0; \
		do_string (W, prompt_str); \
		W->trace = trace; \
		W->stack = W->stack - 1; \
	} \
	W->line_read = w_readline (&auto_brackets, &tab_completion); \
	reset_stack (W); \
	if (W->line_read == NULL) throw_error (W, ERRMEM_S); \
	if (W->line_read[0] == KEY_CTRL_D) throw_error (W, QUIT_S); \
	W->save_line_read = W->line_read;
Some exmplanation:


W->top_of_series is a stack holding the different types of series 
being entered in the lexer, defined as:

#define BLOCK_BEGIN_T		58
#define PAREN_BEGIN_T		59
#define LONG_STRING_BEGIN_T	60
#define PATH_BEGIN_T		61
#define GET_PATH_BEGIN_T	62
#define LIT_PATH_BEGIN_T	63
#define BINARY_BEGIN_T		64
#define SET_GET_PATH_T		65


The code about trace is just, if tracing is on or off in World. W->top_of_code 
is a pointer to where the code for the virtual machine in World is 
being created, and W->code is the bottom of that stack in instructions, 
W->top the top. do_string executes a string of World code.
stack *of* instructions
The line
	tv.newline = 1;

sets a newline in the block of code entered. tv is a Tagged Value 
in World, a value with type specification.
The printf ... W->P != NULL is just some debug code, that should 
be removed.
sqlab
29-May-2013
[2501]
as long as you are not inside a string you should also reagard comments
Geomol
29-May-2013
[2502]
I do that in World in the lexer, which parses W->line_read, that 
is being entered into with the code above.

w> b: [ 
[    ; a comment
[    "hello"
[    ]
== [
hello
]
w> ? b
b is a block! of value: [
    "hello"
]
w>
sqlab
29-May-2013
[2503]
what was again the shortcut for switching the enter mode ?
Maxim
29-May-2013
[2504]
CTRL-E  or the little pencil icon above text box
Geomol
29-May-2013
[2505x2]
sqlab, if you mean at the World prompt, it's ctrl-a
The source for w_readline is found here:
https://github.com/Geomol/World/tree/master/src/host
GiuseppeC
30-May-2013
[2507]
Hi,

  REBOL language differs from other languages because you can write 
  "human resembling" code lines.

  During the past weeks I have thought about a way to make more understandable 
  the language in a simple way

   now you can write:

   mypage: read http://www.rebol.com

    I whish to write:

    set the variable mypage: reading from http://www.rebol.com


    It is actually impossible to have this stile but if you add another 
    way of commenting it woul be possible. Lets assume we have a way 
    to start comments with "/*" and and comments with "*/"

    Now we can write


    /*set the variable*/ mypage: /*reading from*/ http://www.rebol.com

    Another line:

    for myvar 1 10 2 [print myvar]


    for /*(set)*/ myvar /*starting from*/ 1 /*reach*/ 10 /*use the stepping*/ 
    2 /* and execute*/ [print myvar]


    Code editors could remove the pairs /* */ and display commenting 
    words in a different color and each line could be read this way:

    set the variable mypage: reading from http://www.rebol.com


    for (set) myvar starting from 1 reach 10 use the stepping 2 and execute 
    [print myvar]


    For people which are learning the language and even for seniors, 
    having this commenting could help a lot.
Geomol
30-May-2013
[2508x2]
I think, you can achieve this with a preprocessor written in REBOL, 
that parse your scripts and remove the comments, before doing the 
script.
Something like:

out: clear ""
script: {

 for /*(set)*/ myvar /*starting from*/ 1 /*reach*/ 10 /*use the stepping*/ 
 2 /* and execute*/ [
		print myvar
	]
}

parse script [some [
	copy s to "/*" (append out s) thru "*/"
	| copy s to end (append out s) 1 skip
]]
do out
GiuseppeC
30-May-2013
[2510]
Geomol, I suppose it is better to have this in the standard language.
Do you think it would be difficult to implement ?
Geomol
30-May-2013
[2511x4]
Not difficult, but is it necessary, and is it rebolish? I haven't 
done a deeper thought about it, but I would guess, it's as easy to 
implement as long strings { ... }.
in the lexer, I mean. After the comment is out, it's done.
But I wouldn't recommend it, as it would make rebol scripts look 
more like the cluster syntax of other languages.
And you could probably find other languages with similar, but other 
syntax, and programmers from those languages would ask for their 
way and on and on. Do it in a preprocessor!
GiuseppeC
30-May-2013
[2515x2]
Geomol, one year ago NickA wrote about a similar feature available 
in LiveCode. Their language is not so flexible as REBOL, if I remember 
correctly only native and not user generated functions have accept 
neutral strings line "at, the, after" to insert in the code.
Isn't a REBOL goal to be more human friendly ?

We all use descriptions and conections words every day. Inserting 
it *for free* inside a line, eeverywhere you want, makes a language 
more readable.
Obviusly "pros" will like not having them but if they think like 
a newbye or even like a semi-pro I suppose they will find the usefullness 
of this imporvemente.
Geomol
30-May-2013
[2517x8]
I think, most will find it harder to read with comments in the middle 
of lines. You can break code over more lines in REBOL, and that way 
add comments in the middle of lines.
do [
	add
	1	; first number
	2	; second number
]
One frind of mine like named arguments to functions in the call of 
the function. You can probably do that in REBOL easily too. Create 
a function, that remove the names of arguments, that is sent in a 
blok together with the values, and then call the real function with 
only the values.
So you could write:

	do-this [add first-value 1 second-value 2]
or something, if that helps.
I like to write as little as possible. :)
Or maybe better than my do-this example, create a dialect, where 
all function calls work with named arguments. The parsing then need 
to look for words, that are functions, find out how many arguments 
they take and remove the argument names. And do it recursively also. 
Should be possible, I think.
Just a crazy thought to consider:

	add (1 ; first arg) (2 ; second arg)
or

	add (1 comment "") (2 comment "")

Doesn't work in REBOL; but you can do that in World.
GiuseppeC
30-May-2013
[2525]
Geomol, I have alway in mind using:

for /*(set)*/ myvar /*starting from*/ 1 /*reach*/ 10 /*use the stepping*/ 
2 /* and execute*/ [print myvar] 
and see it in the editor as:

for (set) myvar starting from 1 reach 10 use the stepping 2 and execute 
[print myvar]
where the "neutral" words are in different colors.