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

World: r4wp

[#Red] Red language group

Pekr
14-Dec-2012
[4709]
Actually old stuff will die off - Mayans thought about the date as 
of the new fresh era, new oportunities, so quite the opposite :-)
Rebolek
14-Dec-2012
[4710]
World has already ended with its closed-source nature :)
DocKimbel
14-Dec-2012
[4711]
Cyphre: don't count on that (at least for Red)! ;-)
Geomol
14-Dec-2012
[4712]
I don't agree. (of course) World is on hold because of lack of finances 
to bring the development forward.
Arnold
14-Dec-2012
[4713]
The World has ended the Maya's before the Maya's could end the World.
Pekr
15-Dec-2012
[4714]
Donated 50 EUR so that Nick has at least something to match :-)
DocKimbel
15-Dec-2012
[4715]
Thanks! :-)
Gregg
15-Dec-2012
[4716]
Other donations have been made as well, but it's great to remind 
people that we need to support Doc so he can focus and keep making 
great progress. Thanks Petr.
Pekr
15-Dec-2012
[4717]
Ah, glad to hear that :-)
Janko
15-Dec-2012
[4718]
I yesterday donated just 15EUR (just for a pizza, and didn't intend 
to mention it here), but if Nick will match it will be 2 pizzas :P
Pekr
15-Dec-2012
[4719]
:-)
DocKimbel
15-Dec-2012
[4720x2]
If I cut each pizza in four parts, that's almost 8 lunches! :-)
Actually, good decent pizza in restaurant is about 3-5€ here, so, 
15€ is at least 3 pizzas!
Gregg
15-Dec-2012
[4722]
Janko, every bit counts. I've donated this month, but I will match 
December donations in a January donation, up to USD$200. So, donations 
in December get double matching up to USD$200, if Nick matches as 
well.
DocKimbel
15-Dec-2012
[4723x2]
Red 0.3.1 released: http://www.red-lang.org/2012/12/red-v031-functions-support-added.html

- function support
- path get/set notation support
- refinement support for native functions
- expressions in parentheses compilation

- new datatypes: function!, paren!, path!, lit-path!, get-path!, 
set-path!

- new actions and natives: find, select, copy, reflect, type?, halt,...

- extended mold, form and comparison operators to all new and existing 
datatypes
- many new mezzanines functions

- modulo and remainder operators on floats implemented for ARM backend
- Quick-Test testing framework ported to Red
- a truckload of new unit tests
- many bugfixes
- about 200 new commits to the Github repository
- updated Red/System formal description document
Gregg: thank you very much!
Gregg
15-Dec-2012
[4725x2]
Wow! That's great Doc.

We'll try to keep you supplied with plenty of pizza. :-)
Is http://www.red-lang.org/p/roadmap.htmlcurrent? You've been making 
so much progress, I'm guessing it's a little out of date.
Marco
15-Dec-2012
[4727]
Why default red's functions refinements value is false?
DocKimbel
15-Dec-2012
[4728x4]
To avoid having to use to-logic when using refinements to pick a 
value in a series. For example:

In REBOL:
    foo: func [/only][pick [1 2] only]
    foo

    ** Script Error: pick expected index argument of type: number logic 
    pair
    ** Near: pick [1 2] ref

In Red: it should return 2.
Note that PICK taking a logic! value is not yet implemented, it will 
be added in the next days.
This is a code pattern I use often, but always find it annoying to 
have to add a to-logic call each time in front of refinements.
Gregg: It will need to be updated a bit, right
Kaj
15-Dec-2012
[4732]
Thanks for supporting Red, Gregg! The others, too
GiuseppeC
15-Dec-2012
[4733]
Great Doc !
BrianH
15-Dec-2012
[4734]
Funny, I usually just reverse the order of the PICK elements and 
use NOT.
Kaj
16-Dec-2012
[4735]
Are only the refinements FALSE, or also extra arguments?
DocKimbel
16-Dec-2012
[4736]
Unused refinements only. Extra arguments are set to none.
Kaj
16-Dec-2012
[4737]
OK, that sounds useful
DocKimbel
16-Dec-2012
[4738]
It is also more consistent, as used refinements are set to TRUE.
Kaj
16-Dec-2012
[4739x2]
Just specifiying a return type adds 68 bytes to a function. Why is 
that?
(In Red)
DocKimbel
16-Dec-2012
[4741]
It shouldn't have any effect on the generated code size. Can you 
send me the function?
Kaj
16-Dec-2012
[4742]
It's the Fibonacci function in the C library binding. I checked in 
a Red version. If you add return: to that it becomes 68 bytes bigger
DocKimbel
16-Dec-2012
[4743]
Does the function becomes bigger or the whole binary?
Kaj
16-Dec-2012
[4744]
The binary. The function would be hard to estimate
DocKimbel
16-Dec-2012
[4745x2]
Then, that's normal, the added size is for dynamically creating the 
extra literals you've added to the spec block. Remember that the 
source code of your function is built-in the final binary, so you 
can use reflection and soon, rebuid the function dynamically at runtime.
Also, you won't find the source code of block literals in text format 
if you scan the binary, because they are stored as code and not data. 
That is the only way currently they can be stored in compiled binaries. 
Storing them as text would need a way to load them and then compile 
them at runtime (it will be possible in the future, but not right 
now).


Anyway, the probably best way to store all those series literals 
is to allow the use of a redbin format. We will have that too at 
some point.
Kaj
16-Dec-2012
[4747]
Ah, thanks
DocKimbel
17-Dec-2012
[4748x2]
New features of the day: 
- SWITCH implemented (/default refinement supported)
- CASE implemented (/all refinement supported)

- FIND and SELECT extended to handle datatype values matching. Example:

    find ["hello" 2 red] integer!
    == [2 red]
Forgot also to mention that PICK and POKE now accept logic! value 
as index.
Chris
20-Dec-2012
[4750]
Re. Hex, how about underscore? Fairly clear and not too dissimilar 
to 0x2FAB notation.

0_ffccbbee 2_11011011 16_2FAB
Jerry
21-Dec-2012
[4751]
Red/System Question: In Struct A, there is a menber which points 
to struct B. In Struct B, there is a member which is a function pointer, 
whose parameter is a pointer to Struct A. ... How can I do this in 
Red/System. This is not a fiction case. I am studying SQLite surce 
code, struct sqlite3_file and struct sqlite3_io_methods are exactly 
like this.
PeterWood
21-Dec-2012
[4752]
This any help?

Red/System []

a!: alias struct! [
  a1  [integer!]

  a2  [integer!]            ;; this is used to hold address of struct 
  b
  a3  [integer!]
]    

f!: alias function! [s [a!]]
f: func [s [a!]] [print [s/a1 lf]]

b!: alias struct! [
  b1 [f!]
]
  
a: declare a! 
b: declare b!


a/a1: 5
a/a2: as integer! b 
a/a3: 0
b/b1: as f! :f

foo: as f! b/b1           
foo a
Jerry
21-Dec-2012
[4753]
Thanks, Peter
DocKimbel
21-Dec-2012
[4754x2]
Jerry: if I understand correctly, what you want to achieve is:

    Red/System [ ]

    structA!: alias struct! [
        p [structB!]
    ]

    structB!: alias struct! [
        fun [function! [a [structA!]]]
    ]


As is, it won't compile in Red/System as structB! is not yet defined 
when defining structA! (and the compile is making a single pass only, 
so can't look ahead). 


The workaround is to define `p` as integer! and use type casting 
when accessing it.


Also note that if you reverse the order of definitions and start 
by defining structB!, you could use the same workaround for `a` argument 
type (define it as integer!, then apply type casting when appropriate).
I have added a new function type today: routine!. It allows to write 
a Red/System function in a Red program. The compiler will marshal 
(or type-cast) the arguments back and forth automatically.

Here is the Fibonacci example rewritten as a routine:

Red [ ]

fibonacci: routine [
    n          [integer!]
    return: [integer!]
][
    either n < 2 [
        n
    ][
        (fibonacci n - 1) + (fibonacci n - 2)
    ]
]


The function body is Red/System code, so it will run at full Red/System 
speed.


Integer! and logic! values are converted automatically, other Red 
datatypes are passed boxed but type-casted as Red/System counterparts 
(as defined in the Red runtime). Hint: floats will be converted automatically 
too.

So, passing and processing a block! series would look like this:

Red [ ]

add-one: routine [
    blk       [block!]
    return: [block!]
    /local value tail int
][
    value: HEAD(blk)
    tail: TAIL(blk)
	
    while [value < tail][
        if TYPE(value) = TYPE_INTEGER [
                int: as red-integer! value
                int/value: int/value + 1
        ]
        value: value + 1
    ]
    RETURN(blk)
]


I haven't yet released the code, it needs a bit more work, it should 
be ready by tomorrow.


The purpose of routine! datatype is to provide access to ultra-fast 
and low-level code for Red program in a simple way. The design is 
not yet fully set in stone, so suggestions and comments are welcome.
Endo
21-Dec-2012
[4756]
That's cool, it's something like rebcode.

How about something like having a block of Red/System code inside 
Red code?

System [...some R/S code...]
Jerry
21-Dec-2012
[4757]
Endo, what you want is described in Section 17 in the Red/System 
Spec   http://static.red-lang.org/red-system-specs.html#section-17
Gregg
21-Dec-2012
[4758]
Very cool Doc!