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

World: r4wp

[#Red] Red language group

DocKimbel
10-Apr-2013
[6938]
It's too early to stress test the memory manager, as it's not yet 
completed for the handling of bigger series.
Pekr
10-Apr-2013
[6939]
Maybe it causes stress to Gregg, that he can't stress-test :-)
Endo
10-Apr-2013
[6940x4]
Here you can compile your Red scripts online and then download the 
compile executable file:
http://bircomteknoloji.com:8181/
You can use it to test for compiling Red scripts and generated executable 
file.
Doc: Red header is case sensitive, red [ ] doesn't compile, "Invalid 
Red program" it says. Red [ ] works.
Some antivirus programs gives false alarm for compiled executables, 
so I think its better to not spread this site too much, people can 
think that it downloads viruses.
Gregg
10-Apr-2013
[6944]
Ah, that would explain my errors Endo. I didn't include a header.
DocKimbel
10-Apr-2013
[6945x5]
Endo, nice work! Could come handy sometimes.
For false alarms from AV software, please report them to me so I 
can contact AV vendors to whitelist Red binaries.
For Red header, I've made it case sensitive on purpose as, unlike 
Rebol which is a very uncommon name, Red is very common, the risk 
of a false header detection is much higher (for scripts embedded 
in HTML, makedoc document, etc...). So the case-sensitivity would 
lower the number of false positives. An added benefit is that it 
forces users to write Red name correctly, so not RED or red.
Endo, you could even make it a webservice that could be used with 
a simple WGET call from a command-line. ;-)
Also, when asking for the file to be downloaded, you should rename 
the file to something more human-friendly or ask the name from the 
user. You can use Content-Disposition HTTP field for doing that easily. 
Here's an example from one of CureCode's RSP:

        response/buffer: get-modes file 'full-path	

        response/set-header 'Content-Disposition  rejoin [{filename="} name 
        {"}]
Gregg
10-Apr-2013
[6950x3]
On the header, having it be Red may lead to the most false positives. 
If it's at the top of a file, it would normally be capitalized.
As long as it must be followed by a left bracket, you should be OK 
though.
I do agree that it avoids being confused as an acronym.
Kaj
10-Apr-2013
[6953]
It was my understanding that string/rs-head returns a UTF-8 cache 
of a string. How can I get this value?


I'm trying to get UTF-8 back that I fed in. The problem I'm having 
is the following:

write %syllable.org.html read "http://syllable.org"

This writes out just one character instead of the expected file.
Gregg
10-Apr-2013
[6954]
Doc, on stress testing, I was just trying to do eyeball speed testing 
of some mezz code.
Kaj
10-Apr-2013
[6955]
I agree that the allocator is important to fix
Gregg
11-Apr-2013
[6956x6]
On the stress testing, and keeping in mind that I fully expect Red 
to be slow at many things at this stage, It is really wonderful to 
see that it's not. Yes, these are still small tests, but Red still 
impresses me with what works and works so well.
And because there are holes, it makes me think about different ways 
to solve things, which is fun.
My small test was for a FILTER function:

filter: function [
	"Returns all values in a series that match a test."
	series [series!]

 test [function!] "Test (predicate) to perform on each value; must 
 take one arg" ; TBD: any-function!
	/out "Reverse the test, filtering out matching results"
][
    result: copy []
    ; The lambda here is like QUOTE, but it evaluates.
    op: either out [:not] [func [val] [:val]]
	foreach value series [
		if op test :value [append/only result :value]
	]
	result
]
Given the block size limit, I used a block with 60K elements in it:

b: append/dup copy [] [1 b #c "d"] 15000
Then tested with simple type testing funcs. e.g. 

filter b :integer?
filter/out b :integer?
etc.
I have to loop >5 times before I see *any* delay in the console prompt 
returning. At 10 times, it seems to take about a second.
Oldes
11-Apr-2013
[6962]
If you check http://www.red-lang.org/p/roadmap.htmlyou can see that 
GC is made just from 10%. You are allocating large memory blocks, 
but do not free them posibly.
Gregg
11-Apr-2013
[6963x2]
Yes, they never get freed. I "freshen" my console frequently. :-)
It doesn't seem to slow down as I continue testing. Just eats memory.
DocKimbel
11-Apr-2013
[6965]
I will have a look today at the reported Curecode issues, then I'll 
get back to Red coding, probably working first on the exception support 
for Red/System (in order to be able to implement EXIT/RETURN support 
for the interpreter).
Endo
11-Apr-2013
[6966]
Thank's for the feedbacks, making a webservice-red-compiler is a 
nice idea, but I made it for lazy people like me to be able to compile 
Red scripts easily. 

Doc: red-lang.org is on a Cheyenne server or a normal hosting service?
DocKimbel
11-Apr-2013
[6967]
Only some static resources are on Cheyenne server, the rest is hosted 
by Blogger (Google).
Endo
11-Apr-2013
[6968]
For false alarms from AV software, please report them to me so I 
can contact AV vendors to whitelist Red binaries.

, how should I report it? What to include? I can prepare zip package 
with those exe files and some info (OS versions, AV versions, etc.)
DocKimbel
11-Apr-2013
[6969x4]
Just give me the AV software name first, then the source file name 
and compilation optons (if any).
You should also upload first your binary here: https://www.virustotal.com/en/
If the AV software from virustotal doesn't give you the same error, 
you might have an older AV version.
You can post here the link to the virustotal report.
Endo
11-Apr-2013
[6973x3]
Oh sorry, when I say AV I meant AVira :) Avira Free Antivirus: http://www.avira.com/free-av
Ok I've uploaded to virustotal.com, Detection ratio:	 1 / 46, only 
avira-antivir says "TR/Crypt.XPACK.Gen" virus found.
Here is the link:

https://www.virustotal.com/en/file/2db471babe53dedbd6adf0c5c112976a6692ad000aea83dfa93890f6d1e1b43b/analysis/1365683598/
DocKimbel
11-Apr-2013
[6976]
So you just compiled tests/hello.red or did you use a custom script?
Endo
11-Apr-2013
[6977]
my script is:
Red [ ]
print "hello"
DocKimbel
11-Apr-2013
[6978]
Ok, thanks, will try to reproduce the false alarm and will contact 
AVira for reporting it.
Gregg
12-Apr-2013
[6979x2]
Since it's early days in Red, I'm toying with a lot of ideas and 
revisiting old REBOL funcs as I port them. JS has an interesting 
spin on MAP. I thought I'd see how hard it would be to do in Red.
; JS-like MAP. The order of args to the function is a bit odd, but 
is set

; up that way because we always want at least the value (if your 
func takes

; only one arg), the next most useful arg is the index, as you may 
display

; progress, and the series is there to give you complete control 
and match

; how JS does it. Now, should the series value be passed as the head 
of the
; series, or the current index, using AT?
map-js: func [

 "Evaluates a function for each value(s) in a series and returns the 
 results."
	series [series!]

 fn [function!] "Function to perform on each value; called with value, 
 index, and series args"
	/only "Insert block types as single values"
	/skip "Treat the series as fixed size records"
		size [integer!]
][
	collect [

  repeat i length? series [   ; use FORSKIP if we want to support /SKIP.
			keep/only fn series/:i :i :series ; :size ?
		]
	]
]
;res: map-js [1 2 3 a b c #d #e #f] :form
;res: map-js [1 2 3 a b c #d #e #f] func [v i] [reduce [i v]]
;res: map-js [1 2 3 a b c #d #e #f] func [v i s] [reduce [i v s]]
;res: map-js "Hello World!" func [v i s] [pick s i]
DocKimbel
12-Apr-2013
[6981x2]
Nice and short implementation! :)
An important note about such code: passing a function! as argument 
is not supported by the compiler yet, so this function could only 
work in the interpreter currently (from console or from a DO block).
Gregg
12-Apr-2013
[6983]
Good to know. Thanks. I'm trying to stay just a few steps behind 
you in what I try. :-)
DocKimbel
13-Apr-2013
[6984x4]
For Red/System fans, here's some new toy: exceptions! Here's a simple 
example for starting:
foo: func [[catch]][
	print "2"
	throw 10
	print "KO"
]

print "1"
foo
print "3"
print ["^/thrown value: " system/thrown lf]
will output:

123
thrown value: 10
A deeper nested example:

foo2: does [
	print "3"
	throw 100
	print "KO"
]

bar: func [[catch]][
	print "2"
	foo2
	print "KO"
]

print "1"
bar
print ["^/thrown value: " system/thrown lf]