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

World: r4wp

[#Red] Red language group

Kaj
25-Jul-2013
[9673x2]
is faster or shorter than
either yes [1] [2]
DocKimbel
25-Jul-2013
[9675]
Not sure it is faster, but it takes one less statically allocated 
block.
Kaj
25-Jul-2013
[9676x2]
Aren't those EITHER block compiled away into code?
blocks
Gregg
25-Jul-2013
[9678]
I have already thought, since Doc mentioned the small gains Red would 
see from compiler optimizations, that having a Red level optimizer 
might be even better.
Kaj
25-Jul-2013
[9679]
I have understood it the other way around
DocKimbel
26-Jul-2013
[9680x2]
Kaj: depends if it's in a function body or in global context, and 
if the bodies are stored or not.
Gregg: we'll add optimizations at all possible levels.
Kaj
26-Jul-2013
[9682x2]
How does the compilation differ between global context and a function 
body (apart from storing)
?
DocKimbel
26-Jul-2013
[9684]
The generated code for global and local variables is different.
Kaj
26-Jul-2013
[9685]
I think I still like the EITHER better, then. It's more natural
DocKimbel
26-Jul-2013
[9686]
I find the PICK version easier and faster to type, but that's just 
personal taste. :-)
Kaj
26-Jul-2013
[9687x2]
I spend a very small part of my time typing
The PICK method seems more like an interpreter optimisation to me
DocKimbel
26-Jul-2013
[9689]
I think it's good to have both from many perspectives, one being 
that EITHER reduces the values while PICK does not. I tend to use 
PICK for passive values and EITHER for evaluating expressions. You 
can also express a different intent using PICK than EITHER, think 
how a static code analysis tool (e.g. an IDE) would interpret it.
Kaj
26-Jul-2013
[9690]
Agreed
Gregg
26-Jul-2013
[9691]
Use them to express intent + 1
Arnold
28-Jul-2013
[9692x4]
I have taken a look at XieQ's version of the Mersenne Twister and 
found that that too does not produce exactly the same results as 
'my' C version of the program. One of the issues is the shift result. 
I give this example:
int: 80000000h
print ["Value int: " int lf]
shi: int >> 31
print ["Value shi: " shi lf]
Result is Value int: -2147483648
Value shi: -1

afaict the C version using unsigned long integers this shift action 
results in +1
After that the xor with this different signed number get rid of the 
sign. 

Another little thing is the adding of the count/sequence number is 
different when added to a positive/negative number.

Getting the exact same result is important to me. While this version 
is good enough to use as random for throwing dice in a game of Yahtzee, 
distribution of randoms in longer term could be more predictable 
than with the "official" version, which would be a bad thing when 
used in encrypting.
(Because of the multiplication factor used a small difference in 
startvalue will result in completely incomparable resulting numbers)
Would like to see the hex representation of various inbetween results. 
Is that possible in Red/System?
Kaj
28-Jul-2013
[9696x2]
The C library binding has form-hex, or you could use print-form
To shift as an unsigned number, you should use >>> instead of >>
Arnold
28-Jul-2013
[9698]
Thnx Kaj!
DocKimbel
28-Jul-2013
[9699x3]
If you want to print an integer in hex format in Red/System, you 
can also achieve it by a simple casting to a pointer type:

    print as byte-ptr! int
FYI, I've been mostly offline these last days as a friend of mine 
came to visit me from Paris. Also, that's the moment my Windows chose 
to die, not sure if it was triggered by a hardware issue or not. 
So, I'm now in the process of setting up a new system, moving to 
64-bit and bigger disks. I hope to be able to get all my tools back 
by tomorrow, so I'll be able to start committing changes again.
I can't wait to have a cross-platform Red IDE and forget about what 
"installation" means. :-) A Red OS would also help a lot. ;-)
Gregg
28-Jul-2013
[9702]
Sorry for the hardware problem Doc. You can blame me. I sometimes 
think "How can I get Doc to write a Red OS...?"
DocKimbel
28-Jul-2013
[9703x3]
Hehe :-)
We'll to that too at some point in the future.
We'll <come>...
Arnold
28-Jul-2013
[9706x2]
What would be the difference in Red/System between
#define var value ;and 
var: value 
because both are valid? When to use either of them?
Ah read documentation again. Constant form, macro substitution. #define 
should be hardcoded, non variable so faster in executing.
Gerard
28-Jul-2013
[9708x4]
How do we install support for Unicode when using a Windows console 
? When I open Hello.red with my MS Word, the unicode characters are 
visible but when I run it my "invite de Commande" I can't see them, 
they are replaced by ? Must we go the old way of page codes as when 
we were under DOS boxes ? I hope not ...
I'm trying this small Rebol 3 sample code under Red console and I 
get 3 load errors plus a real error at the end  - invalid char!. 
char ending delimiter " not found! unmatched ] closing bracket! word 
has no value.  Is it OK ?  Here is what I tried to enter : red>> 
 #"^(3B1)"     ; char as a hex encoded literal
It's used as my first step to get some code translation on the Perl 
Cookbook (pleac project ). the first exercises are about strings. 
I encoded the small snippets using Rebol 2 already and now I was 
testing the same code for Red and later I 'll attack the same for 
Rebol 3. I'll then submit in the REBOL SCHOOL  or another dedicated 
group this first trial for revision and correction. May be their 
introduction could aslo be revised to ttake into account Rebol and 
/or Red internals subtleties which I don't really master... yet!
Even the Windows help was not useful since they state that  some 
installed programs can't display the foreign UNICODE characters. 
In this cas they simply offer me to select the language in which 
these characters will be displayed. I selected French since it was 
already selected and since it is convenient to me if I want to understand 
anything displayed here !!!
Pekr
28-Jul-2013
[9712]
IIRC Red console does not support Unicode yet ...
Gerard
28-Jul-2013
[9713]
OK thanks. But then how could Doc test his Hello.red output ?
Pekr
28-Jul-2013
[9714x2]
Compiled?
But I might get it confused, so better wait for Doc or Kaj to appear 
:-)
Gerard
28-Jul-2013
[9716x7]
Yes it seems logical. I will try it then!
I also get some ? instead of the chars that Word is displaying ! 
May be our american products can't display this correctly from the 
Win Console too ...
Except if we change the regional language to be able to dusplay it 
but then I'll have to chage it for every foreign language and this 
is not the good way to go I hope !!!
May be that the character sets offerd for selection under the properties 
tab of the Win console don't offer this display choice but I don't 
know how to install others. Currently I only have True Type Lucida 
Console, True type Consolas and Raster... : (
Will look further in Windows Help - for how to install other char 
sets under the Win console ...
It' located under the Panneau de configuration (accessible using 
MSConfig) but the problem I have is that I don't have the admin privilege 
to add such a char set - I found one which is described as ARIAL 
MS UNICODE which could do the job. I'll try again...
;-----------------------------
mystr: "^/"        ; a newline character
print "test-1" probe mystr print length? mystr

mystr: "^(line)"   ; a newline character (alternative)
		     ; last one is converted into "^/"
print "test-2" probe mystr print length? mystr

mystr: "\n"        ; two characters, \ and n
print "test-3" probe mystr print length? mystr

;-----------------------------
mystr: "Jon 'Maddog' Orwant"  ; literal single quote inside 
                              ; double quotes
print "test-4" probe mystr print length? mystr

mystr: {Jon "Maddog" Orwant}  ; literal double quote inside 
                              ; braces (also used for multilines)
print "test-5" probe mystr print length? mystr
;-----------------------------
mystr: {
This is a multiline string literal
enclosed in single braces.
}
print "test-6" probe mystr print length? mystr

mystr: "^(line)"   { a newline character (alternative)
		      the last one is converted into "^/" by Rebol}
print "test-7" probe mystr print length? mystr

;-----------------------------

; There si no way to change the delimiters for strings
; No way either to define strings using "Here Documents" form

;-----------------------------