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

World: r3wp

[Red] Red language group

Gregg
27-Feb-2011
[1]
This group is for discussion related to DocKimbel's (SoftInnov) Red 
language.
BrianH
27-Feb-2011
[2]
http://www.red-lang.org/
GrahamC
27-Feb-2011
[3x2]
whoever created this group .. check your spelling!
or your keyboard :)
BrianH
27-Feb-2011
[5]
Limits relative to REBOL (based on the slides):
- Static scope.
- No dynamic binding.

- Some code won't work because it's too abstract for the type inferencer 
to figure out.


There are likely a few other bits here and there, but that's not 
very limited. A lot of non-optimized REBOL code should work, assuming 
the syntax is the same.
Dockimbel
27-Feb-2011
[6]
Good summary.
Andreas
27-Feb-2011
[7]
Except that if Red (not Red/System) is to be statically compiled 
as well, that'll make the language quite different to REBOL. In fact, 
I'd assume that except for some superficial syntactic similarities, 
it won't have much to do with REBOL at all.
BrianH
27-Feb-2011
[8]
I'm a little worried about the (literal form accessible) part of 
your pluggable module type (UDT) feature. Languages with user-extensible 
syntax are almost impossible to debug.
Gregg
27-Feb-2011
[9]
Thanks Graham. Typo fixed.
BrianH
27-Feb-2011
[10]
Andreas, you can compile a large subset of code that REBOL would 
also accept. The underlying semantics would be different, but not 
enough so for it to matter to most programmers.
Dockimbel
27-Feb-2011
[11x2]
I was planning to use a desambiguation check on loading UDT with 
literal parsing rules, to avoid collision with other type's syntax 
and delimiters. It still need to be prototyped and tested with real 
code to see if it's worth it.
Brian: right, it will look and even feel very much like REBOL to 
most programmers that don't rely on higher level semantics and complex 
hand-optimized code.
BrianH
27-Feb-2011
[13]
I prefer code that can be loaded by a dumb loader, code that doesn't 
have different meanings depending on which module is loaded even 
before the code runs. I've had a lot of experience with different 
languages, and any language which requires you to read the source 
of its entire runtime library to debug properly is a bad one (I'm 
looking at you, Delphi and C++).
Oldes
27-Feb-2011
[14]
Do you have any prototype already? So we could see some code example?
BrianH
27-Feb-2011
[15]
One advantage to using the R3 data syntax is that you could have 
a Red dialect in R3 as an extension. It's up to you whether this 
is a value.
Dockimbel
27-Feb-2011
[16]
I have a working prototype of Red/System's tool chain (compiler+linker), 
but I need to clean-up the code first, add some runtime primitives 
(there's currently only PRINT and just working on string literals, 
so quite limited). I was thinking about making it available next 
week on github. Then I will start publishing every incremental revision 
there. I'll do an annoucement this week about that on Red's blog.
BrianH
27-Feb-2011
[17x2]
No reason why competing projects can't cooperate as well, licenses 
permitting :)
That "Too abstract code" section... With type inferencing you could 
manage abstract code. It might require declaring the types of function 
arguments before path syntax can be used, but that isn't as big a 
deal as it sounds.
Dockimbel
27-Feb-2011
[19]
In theory, you should be able to build some R3 extensions in Red/System 
(I would need to implement the DLL linker support and 3rd-party DLL 
exported functions mapping first).
BrianH
27-Feb-2011
[20]
It would also be possible to make the function argument type syntax 
more complex than that of R3, providing more detailed information. 
On the other hand, duck typing may be sufficient to determine what 
is necessary.
Dockimbel
27-Feb-2011
[21]
Brian: true, I'm not yet sure how far the inference engine could 
push the limit without becoming too complex to maintain, so I've 
put this early warning to show that there will be a limit (even I 
don't know yet where it will be precisely).
BrianH
27-Feb-2011
[22x2]
And that limit could be increased with time.
I like Go's type system, where there are interface types but you 
don't have to declare that your objects implement those interfaces. 
The type checker can figure out for itself whether the object matches 
any interface type. It's like formalized duck typing. Go's object 
model - no classes or inheritance - adapts really well to REBOL, 
so it's a good language to mine for ideas.
Dockimbel
27-Feb-2011
[24x2]
And that limit could be increased with time.

 Exactly. As Red's compiler will be coded in Red (once the bootstrapping 
 phase will be over), every new feature added to Red will benefit 
 to the compiler itself.
Go: It's in my scope of languages to study, like Scala, Lua, Factor 
and Rust.
Kaj
27-Feb-2011
[26]
Falcon :-)
Dockimbel
27-Feb-2011
[27]
Ah yes, I'll add that one too to my list. Thanks for the reminder 
:-)
Ladislav
28-Feb-2011
[28]
Andreas: "Except that if Red (not Red/System) is to be statically 
compiled as well, that'll make the language quite different to REBOL. 
In fact, I'd assume that except for some superficial syntactic similarities, 
it won't have much to do with REBOL at all." - nevertheless, if Red 
will be a sublanguage of what I call the Data Exchange Dialect, it 
will be a REBOL dialect in my opinion, no matter how limited/unlimited 
it is going to be.
Pekr
28-Feb-2011
[29]
Althought not precisely undestanding the topic, I might agree with 
Ladislav. Now if I am not wrong, then e.g. Cyphre's JIT code could 
be regarded being kind of REBOL dialect - it looks like REBOL, it 
might have syntax like REBOL, you just can't do all the tricks with 
it. Whereas we could not say the same about e.g. a RebCode? Does 
it make sense, or am I wrong?
Ladislav
28-Feb-2011
[30]
Whereas we could not say the same about e.g. a RebCode?
 - actually, we could say the same about RebCode as well
BrianH
28-Feb-2011
[31x2]
Doc, you might also consider making your type inferencer aware of 
the ASSERT function. ASSERT/type in particular would provide useful 
information, and can be evaluated statically as long as you don't 
let the function be overriden.
Quick questions about Red/System:

- Do you have DO of block expressions (getting from a word, returning 
from a function), rather than scripts or inline blocks?

- Are the conditional control and loop functions built into the language, 
or are they functions?

- Can the aforementioned functions take block expressions, or only 
inline blocks?
Dockimbel
28-Feb-2011
[33]
ASSERT: I'll look into that.

DO of block expressions

 nope, it's too high-level for Red/System. Remember that there's no 
 block! datatype in Red/System, we're talking about a C-level language. 
 In Red, you'll be able to use DO (as well as REDUCE and COMPOSE) 
 pretty much the same way as in REBOL (will require the JIT).


Control flow functions: built into the language for Red & Red/System. 
They'll be expecting inline blocks as argument, but when the JIT 
will be available, this could be extended to block expressions.
MikeL
28-Feb-2011
[34]
Doc: LuaJIT.org may have some good parallels as well just LUA
BrianH
28-Feb-2011
[35x4]
I figured as much, but thanks for the clarification.
ASSERT/type can do deep type checking of paths, and after the function 
returns the code can assume that the assertions are true. This can 
help with making code that would otherwise be too general for the 
inferencer to handle be really specific. To work best, ASSERT would 
also need to be built into the language, like the loop functions.
When ASSERT is compiled the statically determinable assertions can 
be dropped from the output code, leaving only the stuff that needs 
to be checked at runtime.
Building in the type test functions into the language would have 
the same effect. The type inferencer could determine some of them 
statically. If they are regular functions, that would require partial 
evaluation to get the same effect.
Dockimbel
28-Feb-2011
[39]
MikeL: LuaJIT is definitely the best model to follow for Red's JIT, 
at least performance-wise.


BrianH: thanks for the insightful explanation. This seems like a 
nice way to make the inferencer smarter. Is ASSERT used a lot in 
R3 mezz code so far?
BrianH
28-Feb-2011
[40x6]
Yes, for situations that the function type specs can't handle. It's 
mostly used for making code more bulletproof, but it can speed things 
up too. Even more so in Red since the runtime overhead could be eliminated 
when unnecessary.
My old version of LOAD used it a lot, but the new version uses the 
CASE/all style to get the same effect with less overhead.
See sys/make-module* for a good example of its use now.
ASSERT and ASSERT/type don't have a way to test the number and type 
compatibility of function arguments for first-class functions. It 
might be worth looking into a way to check that, perhaps as an extension 
of ASSERT, which could be ported to R3 as well. ASSERT is also high 
on the list of functions to backport to R2 as a native function.
Code like this in FIND-ALL:
    assert [series? orig: get series]

could be internally rewritten into this as part of the compilation 
process:
    orig: get series assert/type [orig series!]
You should definitely make sure that Red/System supports CASE and 
CASE/all, since the style that those functions allow leads to really 
efficient code.
Dockimbel
28-Feb-2011
[46x2]
I didn't need a CASE-like statement so far in Red/System, so it's 
there yet. Current implemented control flow statements: IF, EITHER, 
UNTIL, WHILE, ANY, ALL. So implementing CASE should be doable.
it's there
 => it's not there
BrianH
28-Feb-2011
[48]
Look at the source of LOAD and sys/load-header for some good examples 
of the CASE/all style. It's worth supporting.
Dockimbel
28-Feb-2011
[49]
I'm sure it would be nice to have it, but my short term goal with 
Red/System is to just code the minimal set of primitives required 
to build the upper layer (Red's runtime layer). I was hoping that 
other developers could keep expanding/improving Red/System while 
I would progress on the Red part.
BrianH
28-Feb-2011
[50]
Good point.