Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 13 2016 03:25
    @PeterWAWood banned @Vexercizer
Softknobs
@Softknobs
@9214 In this case the 0 value that comes from an external dll seems to be considered as "NULL" in the c-string context. I guess there is no way for Red to see the difference in this case. This only happens when 0 is the last value, other 0 values are converted correctly (ex: #{090010} middle 0 value remains). Anyway size? does the trick. Thanks for your help.
Vladimir Vasilyev
@9214
@Softknobs you're welcome.
Softknobs
@Softknobs
Just a piece of advice to beginners in R/S: note that every example saying the -r parameter is required can also use the -u and -c afterwards.
Maybe this is obvious to experienced R/S developers but I found it by accident. This means that the compilation with -u will take a bit more time than -r the first time you compile your script but just a few seconds on subsequent compilations since you can use the -c parameter.
In my case compiling anything with -r takes around 90 seconds and I almost gave up Red althogether just because of compilation time in trial and error debugging phases...
I don't think this is clearly mentionned in the R/S documention but I just found this blog post about this behaviour while writting this message: https://www.red-lang.org/2017/03/062-libred-and-macros.html
Sorry if you find this to be "obvious" stuff but I wanted to share this experience as it changed a lot my Red experience.
Vladimir Vasilyev
@9214

@Softknobs thanks for sharing your experience! Red/System specification describes the language itself (i.e. syntax and semantics), which is totally unrelated to how toolchain functions (compilation flags and the like).

I think the best place to document your gotchas is our Github wiki, which already has a lot of R/S-related pages. Feel free to update any of them (this one seems like a good fit) or create a new one.

Vladimir Vasilyev
@9214
Also, note that usage of new runtime calls in your code (after -u) requires rebuilding of a new custom libRedRT, which in turn requires cleanup with red clean command.
François Jouen
@ldci
New samples and doc for ffmpeg and Red: https://github.com/ldci/ffmpeg.
Vladimir Vasilyev
@9214
@ldci good job as usual, but may I kindly suggest to not cross-post your announcements in multiple channels? /red one is enough.
Petr Krenzelok
@pekr
I will gladly propagate in terms of the Facebook group, once I get home ....
Vladimir Vasilyev
@9214
By "channels" I meant "Gitter rooms" of course, my bad.
François Jouen
@ldci
@9214 : OK no problem , I'll focus on red git room
GiuseppeChillemi
@GiuseppeChillemi
An "announce" room like we have on AltME would be really good !
(And also its announce-reply companion)
Gregg Irwin
@greggirwin
We use red/red for that. Gitter make it harder to manage a large number of groups than AltMe did, so we have to limit special purpose groups that are public.
GiuseppeChillemi
@GiuseppeChillemi
@greggirwin I agree with you. Lets postpone it if red/red could be used for announces.
Mel Cepstrum
@melcepstrum
how to invert sign of a variable in Red/System? like x = -x in C
and where can i find information about math functions supported by Red/System (e.g. sqrt, atan2, tanh ...)?
Vladimir Vasilyev
@9214
@melcepstrum
  • two's complement (1 + not x)
  • here
Mel Cepstrum
@melcepstrum
@9214 thanks, and for floats, -1.0 * x ?
Vladimir Vasilyev
@9214
Well, you can actually use multiplication by -1 in either case.
Mel Cepstrum
@melcepstrum
ok, i thought there is unary operator
Respectech
@Respectech
negate should also work, no?
Semseddin Moldibi
@endo64
@Respectech There is no negate in R/S, only in Red.
Respectech
@Respectech
Oh, I missed the part where it was R/S.
luce80
@luce80
@melcepstrum also x: 0 - x
Mel Cepstrum
@melcepstrum
@luce80 thanks
Pranav
@psahani21_gitlab
I require a systems programming language for an upcoming project of mine. I like Red a lot as a language so I figured I would use Red/System; however, I'm finding it hard to justify using it over Rust. Rust offers safety features such as its borrow checker, and it doesn't seem like memory-safety or thread-safety is planned to be implemented in Red/System. So does anyone know if there are any plans to implement any safety features in Red/System sometime in the future?
Gregg Irwin
@greggirwin

Red/System will likely stay at the C level, maybe with some features added in the future, but more "advanced" system level dialects may be done as experimental or permanent variants of R/S. e.g. there could be a Red/System/Safe version that adds memory safety features and compiles to R/S. It could probably even be done with macros.

One of the issues is that you have to give things up to get safety, even Rust does, so R/S will always be kept simple and unsafe, like C.

Vladimir Vasilyev
@9214
@psahani21_gitlab you're comparing apples to oranges. R/S was designed to give user full control (foot-shooting and all), with tight Red integration in mind - it's not even a language per se, but a system programming DSL. All safety features are postponed for R/S 1.0 experiments.
Another thing is why try to apply Rust mindset where it doesn't fit? R/S is unsafe by design, but Red is safe by design; so, combine both (that was the initial idea anyway).
Pranav
@psahani21_gitlab
Ok, thanks for the replies
Gregg Irwin
@greggirwin
Well, one of the great things about being full stack is that we can experiment, you macro fiends you--but also without them, by trying new features and generating R/S that could then be incorporated directly if there's a benefit. There will surely be some very low level bits that might need some custom support in the R/S compiler, but that's a future conversation.
hiiamboris
@hiiamboris
Why can't I declare pointer! [logic!] in R/S?
Vladimir Vasilyev
@9214

@hiiamboris spec says that

logic! pointer is not needed

Go figure :smile:

hiiamboris
@hiiamboris
:D
Nenad Rakocevic
@dockimbel
R/S (pre-Red 1.0) is supposed to serve only as a low-level layer for Red using a throw-away implementation in Rebol, so many features that we could add were left out. Once we get the toolchain ported to Red, then we can add many extra features. You can use pointer! [integer!] as an alias to pointer! [logic!], so strictly speaking a "logic! pointer is not needed". ;-)
Nenad Rakocevic
@dockimbel

@psahani21_gitlab

So does anyone know if there are any plans to implement any safety features in Red/System sometime in the future?

R/S provides already type-safety, which is the most important one. For Rust-like "memory safety" features, they are a bad match for R/S as stated by Vladimir, as R/S aims to give full control over the hardware (going even further than C language). Once we add proper array support, you'll get bound-checking. A full-blown borrow-checker could be considered for experimentation, but not by copying the over-complicated approach from Rust.
If you really require a "system programming language" for your project, you are likely to interface with low-level hardware and/or system libraries, which means using unsafe mode in Rust. For thread-safety, we have a theoretical solution for that, if the prototype proves it viable, we should have it before 1.0.

Softknobs
@Softknobs
Hi, can I find somewhere the list of Red/System functions? For example I am trying to figure if there is a function to compare c-string! types (in Red it would be "a" = value) or if there are functions to work with series! (for example to resize a series). Is there some documentation or code I can look into to figure out if functions already exist? Thanks.
hiiamboris
@hiiamboris
Unfortunately, it's not documented yet. You'll have to poke around ☺
c-strings are compared using memcmp, while every Red type has it's own funcs to deal with - can be found here.
This tool helps me a lot as it sort of understands the syntax. Sometimes though, a good old file search is your best friend.
Softknobs
@Softknobs
@hiiamboris Thanks! libc.reds is very interesting. Your tool is also nice however it is almost impossible to download it and move around with BitDefender installed because it detects it as a virus. This seems to happen frequently with Red executables.
Vladimir Vasilyev
@9214

@Softknobs

can I find somewhere the list of Red/System functions?

Dig into R/S runtime, it shouldn't be very hard to follow, as it is kept relatively small.

if there are functions to work with series!

series! simply don't exist at Red/System level, they are a part of Red runtime (written in Red/System).

Is there some documentation or code I can look into to figure out if functions already exist?

Aside from the official spec? Not that I know of.

WRT BitDefender: it's one of the bad AVs (others are Avira, McAffee and Windows Defender) that frequently cause us troubles. Either whitelist all Red-related directories or consider to switch to another vendor.
Softknobs
@Softknobs
@9214 Thank you for the hints. I will browse the runtime. About series! I was thinking about arrays but I see now there are only literal arrays, so they can't be changed. Is there something close to an array, except cstring! ? Are we supposed to work with pointers and cstring! only? I am not used to C at all and working without an array type is something new and challenging to me.
hiiamboris
@hiiamboris
Let us know when you really need an array, we'll help you do what you require using pointers.
Softknobs
@Softknobs
Hi, is there a way to work with thread at this point either in Red or Red/System? I have a R/S script using a C webserver (libmicrohttpd) which is multithreaded.
My Red callback is called correctly to handle requests. However if there are many requests at once, and I use #call I get errors:
  • if Red function is empty => no error
  • if Red function has a simple printstatement with static text => access violation, it looks like a previous #call has not ended when this happens.
  • if Red function has a write/binary => on occasions I get a error that write/binary does not support binary! type
    On other occasions, I get errors on waitfunction, though I only use it to keep the program running (wait -1)
    Well, this is obviously related to thread handling, hence my question. I know threads are not supported yet but is there some kind of workaround to have either Red or R/S code handle such situations? Thanks.
Semseddin Moldibi
@endo64
Didn't test but what about creating global mutexes manually (CreateMutex api on Windows) and wait for the release, finishing the previous request's job? It will slow down your server but should solve the issue.
Softknobs
@Softknobs
Thanks for the hint. I already tried to make the whole code blocking and it works. The problem then in the server usage: If an upload is being processed, the server can no longer process other requests. This is why I am looking for alternatives but maybe there is no simple way to do this at this time.
Gregg Irwin
@greggirwin
@Softknobs, @qtxie has done some work in a private branch, but it isn't ready for public consumption yet. It sounds like you'll be a great candidate for testing it though.
Softknobs
@Softknobs
@greggirwin if at some point some testing is needed, I'll gladly do it on my script.
Gregg Irwin
@greggirwin
Thanks!