r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!REBOL3-OLD1]

Graham
12-Apr-2006
[526x2]
Pity we can't take the comments and inject them into here.
the fragmentation of information is just increasing.
Henrik
12-Apr-2006
[528]
anyone know why the priorities of +, - and *, / are swapped. This 
is a little annoying, I think.
Gabriele
12-Apr-2006
[529]
henrik, there are no priorities.
Henrik
12-Apr-2006
[530]
oh well, but it still forces you to rethink your expressions
Gabriele
12-Apr-2006
[531x5]
jaime, i don't think multimethods have been discussed for r3. they 
would be nice... but really only if we get custom datatypes too.
a tend to agree with you, but some people say that priorities force 
them to rethink their expressions...
so, in the end, no rule is easier to remember than some rules, thus 
i got to like the rebol way.
you should be able to find my old eval function to eval (and compile) 
math expressions with priorities and so on.
(was posted to ml many years ago, some archive should have it)
DideC
12-Apr-2006
[536]
It's explain in the doc : priority go from left to right, nothing 
more. The rule is different than the mathematical one we used to 
use. But it's also a "simple" rule, easy to remember.
So, 
>> 3 + 2 * 5
== 25
Sunanda
12-Apr-2006
[537]
gabriele: luckily, Brett had a copy:

http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-message.r?m=rmlLNJK
Otherwise the trail could have ended here:

http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-message.r?m=rmlXSDC
PeterWood
12-Apr-2006
[538]
It was easy to find Gabriele's eval script through the topic index 
at Rebol.org. It's at http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-message.r?m=rmlXWHS
Henrik
12-Apr-2006
[539]
interesting. wonder if it could be made into handling symbolic math...
Pekr
12-Apr-2006
[540]
Gabriele - as for multimethods, aren't we getting custom datatypes 
with rebol3? I thought Carl said that language will be "extensible", 
whatever extensible means though :-)
Vincent
12-Apr-2006
[541]
Priorities would mean more special cases for the evaluation - instead 
of a consistent op! behaviour.

It's not just + * - /, it's for // ** and or xor = > >= <= <> == 
=? too.

The left to right rule is itself quite an improvement in readability 
over the pure form:
>> * + 3 2 5
== 25
JaimeVargas
12-Apr-2006
[542]
Please lets not make the mistake of using C precedence for basic 
ops. It will slow rebol.
Maxim
12-Apr-2006
[543]
and using parens work anyways.
Gabriele
12-Apr-2006
[544]
Petr, about custom types, probably yes, but I don't think this has 
been decided yet; In case we have them, i think that at least TO 
needs to be implemented as a multimethod; then having multimethods 
in general might make sense... but I don't think this is going to 
be very high priority (there are more important things).
Anton
12-Apr-2006
[545x2]
Gabriele, that was very interesting insight into the action dispatch. 
Hmmm... I guess the code-breaking aspect of swapping select's arguments 
as well as the fact that the interpreter would probably be slowed 
down sways me against the idea.
(I seem to remember this very discussion some long time ago...)
[unknown: 10]
12-Apr-2006
[547]
Carl... your speeding in your Blog REBOL 3.0 ...Give us time to think 
through your idea's ;-)
Pekr
12-Apr-2006
[548]
Rebolinth - the speed of blog is ok, what I wonder though is, how 
fast rebol 3 development can go, if there is so many ideas floating 
around :-)
Jerry
13-Apr-2006
[549]
Any information about how L10N & I18N will be implemented in REBOL 
3. Thanks.
Chris
13-Apr-2006
[550x3]
I18N is partially discussed in the Unicode group, I'm not sure it 
has come up on the blog other than it being a goal, as with L10N...
I don't think there is a group here specifically geared toward localization, 
though I know it's a well discussed issue...
From the Roadmap: "Greater Locality Support 

It's time for REBOL to do a better job at supporting native languages 
and character-sets. Our goal to expand support with locality and 
unicode enhancements. In addition, it is a goal to release 3.0 with 
French, Italian, and perhaps one/two other languages as part of the 
standard distribution."
[unknown: 10]
14-Apr-2006
[553]
Yes I thought that that was a strange move... French and Italian..I 
can understand Localisation towards French and Spanish though.. and 
perhpas Asian or Arabic..but what is so special about Italian? (Many 
rebol projects in Italy perhaps?)
Maxim
14-Apr-2006
[554]
Gabriele   ;-)
Gabriele
14-Apr-2006
[555x2]
the fact that i can do the translation :P
i.e. it can be in earlier. others will need community support.
Pekr
14-Apr-2006
[557]
Gabriele - what way in will locale support be done? Will there be 
support for more things, like locale setting for floating point - 
dot or comma, money representation char, etc. ?
Rebolek
14-Apr-2006
[558]
Pekr: this is already solved in current REBOL I think - you can use 
both comma and dot for ffloating point and you can put anything before 
the money sign so you can have Kc$24,50 and so on.
Pekr
14-Apr-2006
[559]
ok, but no centralised container to keep locale related values in 
one logical group ...
Rebolek
14-Apr-2006
[560]
My current job is localisation engineer working on some big software 
and I must say that current localisation/internalisation state is 
total mess. How do I miss good old Amiga catalogs! Such a simple 
idea and still not adapted on Windows. We do patch dlls directly...terrible. 
So I hope R3 will bring something like Amiga Localisation System.
Pekr
14-Apr-2006
[561]
hopefully so .... and you can probably send it to feedback, Carl 
told us he is checking feedback for suggestions ...
Gabriele
14-Apr-2006
[562]
the Amiga way is the rough plan.
Gregg
14-Apr-2006
[563x2]
Is anyone intersted in improving the library interface in R3? I have 
a lib dialect (just posted to REBOL.org), and some notes I'll post 
here. Is it worth some time to put suggestions together for RT, or 
is everyone OK with the existing system?
The current library interface is servicable, but could be improved.

For example, char arrays in C structs are a real pain to deal with,

there is redundancy if you're importing a number of routines, from 

the same library, and extra work is required to deal with pointers
to values.

The biggest issue for me seems to be that I have to use COMPOSE 

heavily to get the results I want, or there's a lot of duplication
in struct and routine defs.

--- Easier Routine Declarations

The only thing I've addressed in my lib interface dialect is
making it easier to declare routines. I posted it to REBOl.org
for discussion:


http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=lib-dialect.r

--- Pointers


This is maybe a bit of an extreme example, but I had to do it, so 
it's not purely theoretical.

    LPINT-def: [value [integer!]] none

    LPINT: make struct! LPINT-def none

This struct shows where a nested struct is needed.

    _FAX_JOB_PARAM-def: compose/deep/only [

        SizeOfStruct    [integer!]      ; DWORD structure size, in bytes

        RecipientNumber [string!]       ; LPCTSTR   pointer to recipient's 
        fax number

        RecipientName   [string!]       ; LPCTSTR   pointer to recipient's 
        name

        Tsid            [string!]       ; LPCTSTR   pointer to transmitting 
        station identifier

        SenderName      [string!]       ; LPCTSTR   pointer to sender's name

        ;SenderName      [struct! [value [string!]]]       ; LPCTSTR   pointer 
        to sender's name

        SenderCompany   [string!]       ; LPCTSTR   pointer to sender's company

        SenderDept      [string!]       ; LPCTSTR   pointer to sender's department

        BillingCode     [string!]       ; LPCTSTR   pointer to billing code

        ScheduleAction  [integer!]      ; DWORD job scheduling action code

        ;ScheduleTime    [struct! (SYSTEMTIME-def)]        ; SYSTEMTIME  
          time to send fax
            wYear       [short]
            wMonth      [short]
            wDayOfWeek  [short]
            wDay        [short]
            wHour       [short]
            wMinute     [short]
            wSecond     [short]
            wMilliseconds [short]

        DeliveryReportType  [integer!]      ; DWORD e-mail delivery report 
        type

        DeliveryReportAddress [string!]     ; LPCTSTR   pointer to e-mail 
        address

        DocumentName        [string!]       ; LPCTSTR   pointer to document 
        name to display
        CallHandle          [integer!]      ; HCALL reserved
        ;_PTR   Reserved[3]  [integer!]      ; DWORD must be zero
        _PTR-0  [integer!]      ; DWORD must be zero
        _PTR-1  [integer!]      ; DWORD must be zero
        _PTR-2  [integer!]      ; DWORD must be zero
        _PTR-3  [integer!]      ; DWORD must be zero
    ]
    _FAX_JOB_PARAM: make struct! _FAX_JOB_PARAM-def none
    _FAX_JOB_PARAM/SizeOfStruct: length? third _FAX_JOB_PARAM

    fax-complete-job-params: make routine! compose/deep/only [

        JobParams     [struct! (LPINT-def)] ; ptr to job information struct

        CoverPageInfo [struct! (LPINT-def)] ; ptr to cover page struct
        return:       [integer!]
    ] winfax.dll "FaxCompleteJobParamsA"

So, the API call returns pointers to structs containing the 
data we want; to get it we need to dereference the pointers
after the call.

    complete-job-params: func [
        /local
            params-ptr cover-ptr    ; API return pointers

            params cover            ; REBOL structs with data from API
    ][
        ; allocate return pointer structs for API call
        params-ptr: make-LPINT
        cover-ptr: make-LPINT

        ; make the API call

        reduce either 0 <> fax-complete-job-params params-ptr cover-ptr [

            ; get data from pointers returned by the API

            params: get-dereferenced-data params-ptr _FAX_JOB_PARAM-def

            cover:  get-dereferenced-data cover-ptr  _FAX_COVERPAGE_INFO-def
        ...



Getting the de-ref'd data is the real pain, and seems like it might
be unsafe in the way I did it, though it worked.

    get-dereferenced-data: func [

        {Given a pointer to memory, copy the target data into a REBOL struct.}

        pointer [struct!]   "LPINT structure whose /value is the data pointer"

        struct-def [block!] "The struct you want returned with data"
        /local struct data orig-pointer result
    ] [

        struct: make struct! compose/deep/only [ ; make wrapper struct
            sub [struct! (struct-def)]
        ] none

        orig-pointer: third struct              ; store original inner pointer

        change third struct third pointer       ; change inner pointer to 
        ref'd data

        data: copy third struct/sub             ; copy data from the inner 
        struct

        change third struct orig-pointer        ; restore inner pointer

        result: make struct! struct-def none    ; make result struct

        change third result data                ; change data in result struct
        struct: data: orig-pointer: none
        result
    ]


--- char arrays in structs, or as routine parameters

You can't just declare a fixed size block or string to do this, 
you have to (AFAIK), have individual elements for each item.
That's a huge pain if you have a 128 element array, so I end
up generating them dynamically. I think that was Cyphre's idea
originally, but I don't have notes on it.

    make-elements: func [name count type /local result][
        if not word? type [type: type?/word type]
        result: copy "^/"
        repeat i count [
            append result join name [i " [" type "]" newline]
        ]
        to block! result
    ]

    GUID: make struct! GUID-def: compose [
        Data1   [integer!]  ; unsigned long
        Data2   [short]     ; unsigned short
        Data3   [short]     ; unsigned short
        (make-elements 'Data4 8 #"@")  ; unsigned char
    ] none


--- MAKE-ing structs

How do other people make structs from prototypes? 

    make-struct: func [prototype /copy /with data] [
        make struct! prototype either copy
            [second prototype]
            [either with [reduce [data]][none]]
    ]


--- BSTR type

I've only needed it for one project, but it might be worth 
finding out if it would be worth adding BSTR support for
Windows, as a routine datatype.
Maxim
14-Apr-2006
[565]
in the best of worlds I'd prefer it if we could read all the info 
from a .h file and convert it into a rebol file ready to load the 
dll...
Gregg, Do you think this is possible?
JaimeVargas
14-Apr-2006
[566]
Max, you want a C pre-processor. Lots of work. I think something 
like swig will be easier.
Maxim
14-Apr-2006
[567x3]
I did a .h file parser a long way back... it was able to find and 
extract function names... but did not tackle the structs....
swig?
couldn't we just base a preprocessor based on something already on 
the net?  arent' there some grammar-based C pre-processor a PARSE 
guru could convert into a dialect?
JaimeVargas
14-Apr-2006
[570x3]
Well it sort of works. SWIG is what a lot of languages use.
Problems that arise with preprocessors is the expansion of #define 
and three traversals.
I think extracting the API of .h is the easy part, but sometimes 
the API use macros and these are the hard part. They can be nested 
macros.
Volker
14-Apr-2006
[573]
When i onceneeded header-fields, i wrote a little program to output 
themand run it.
  print("%i",(&p.selector - &p));
Graham
14-Apr-2006
[574]
Is there a particular reason why the left hand corner in draw is 
0x0, and not the bottom left corner?
Geomol
14-Apr-2006
[575]
It's the point with the first address. Traditional bitmaps on screen 
are addressed from top-left to bottom-right.