Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 01 2018 17:34
    @greggirwin banned @BIjeuca_twitter
  • Dec 03 2017 05:53
    @PeterWAWood banned @matrixbot
  • Sep 28 2016 12:20
    @PeterWAWood banned @TimeSeriesLord
Mårten Hildell
@MartenH
More things I don't understand, in this case why I would need paranthesis around a.
I simply do not understand the difference
>> t: "12345"
== "12345"
>> repeat a length? t [ print t/a ]
*** Script Error: word! type is not allowed here
*** Where: print
*** Stack:  

>> repeat a length? t [ print t/(a) ]
1
2
3
4
5
>>
Toomas Vooglaid
@toomasv
@MartenH Without parenthesis, path notation seeks literal a, but inside parens a is first evaluated to number and only then path is accessed. String is series, and you can access its elements by index numbers but not by literal words. Other structures can be accessed by words, e.g.:
>> t: [a b c]
== [a b c]
>> t/a
== b
>> t: #(a: 1 b: 2)
== #(
    a: 1
    b: 2
)
>> t/a
== 1
>> t: object [a: 1 b: 2]
== make object! [
    a: 1
    b: 2
]
>> t/a
== 1
Petr Krenzelok
@pekr
repeat a length? t [print t/:a]
Vladimir Vasilyev
@9214
forall t [print first t]
Mårten Hildell
@MartenH
Seems I have been coding C for too long...
DVL333
@DVL333
I want to create form with flags (for example, "resize") and options ("menu"). I know how to do it separately, but how to combine them together for the form?
view/options [][menu: ["a" "b" "c"] ]
view/flags [] ['resize 'modal]
Nathan Douglas
@nd9600
Is there a way to have error messages tell you what line they were thrown from? I can only see "Where: append" right now, and I've a lot of appends in my script, so it's a bit hard to debug
Greg T
@gltewalt
@MartenH take a look at pad it might help with what you want
Toomas Vooglaid
@toomasv
@nd9600 I think this is the way:
view/options/flags [][menu: ["a" "b" "c"]]['resize 'modal]
Gregg Irwin
@greggirwin
@MartenH, you'll find your feet in Red soon enough. Just keep asking questions when you need to, and save some time.
@DVL333, I think @toomasv meant to tag you in his answer.
Gregg Irwin
@greggirwin
@nd9600, there is no line information in errors. It would come up at times in the Rebol community, but I haven't seen it requested for Red yet. It's tricky, and Carl talked about it at one point, because there isn't always a concept of "lines". That is, Red doesn't need to maintain new line markers for processing in loaded code. Practically speaking, we use them a lot.
DVL333
@DVL333
@toomasv @greggirwin Yes, i've tried it - OK. Thank you very much!
Toomas Vooglaid
@toomasv
@greggirwin Thanks! :blush:
Mårten Hildell
@MartenH
@gltewalt @toomasv @9214 @greggirwin Thanks..
Greg T
@gltewalt
I was confused earlier. I might still be unclear on what is expected, but - @MartenH is this the result that you were looking for?
>> str: "AB"
== "AB"
>> t: enbase/base str 2
== "0100000101000010"
Vladimir Vasilyev
@9214

@MartenH

Thanks a lot! Was looking for something like "rejoin" , but I could not find it:http://static.red-lang.org/red-system-specs-light.html

on a side note - you shouldn't look at R/S docs, because they are not about Red, but about Red/System, a low level dialect. Here's a list of learning resources, but you also should get familiar with probe, source, help, what, ? and ?? functions.

Greg T
@gltewalt
Best list of all time
RnBrgn
@RnBrgn

@greggirwin

@nd9600, there is no line information in errors. It would come up at times in the Rebol community, but I haven't seen it requested for Red yet. It's tricky, and Carl talked about it at one point, because there isn't always a concept of "lines". That is, Red doesn't need to maintain new line markers for processing in loaded code. Practically speaking, we use them a lot.

Greg, if Red code is just data , why can't the error indicate which element "#" in the series code block the error happened at?

Mårten Hildell
@MartenH
@9214 I'm actually a bit confused about what is in the R/S and in Red. The R/S specification is really good but for specific Red things (#system, etc) I find myself digging in the examples..it will come to me I guess.
Vladimir Vasilyev
@9214
R/S -> C, Red -> Rebol + Forth + Lisp + turtles all the way down
Mårten Hildell
@MartenH
@gltewalt Nope. What I have a string of byte values, so "AB12CD" should become #{AB12CD}. Did @pekr solution and that worked fine..
Is there a "/local" for block scope? I now use things like "t: copy []" to clear things...
Dave Andersen
@dander
@MartenH there is also debase for converting a binary coded string into a binary value: debase/base "AB12CD" 16 (default is base 64)
Mårten Hildell
@MartenH
@dander Yes, that was indeed simpler...
Dave Andersen
@dander
There isn't really such a thing as "block scope" in Red. Each word in independently bound to a context, and some things like functions will bind all the words of their body to a new context, which works a lot like having a function scope. It is one of the deeper topics to dig into, but depending on how far deep you want to go, there are some articles from Rebol on "bindology" that explain it pretty well
Vladimir Vasilyev
@9214
@MartenH not sure what you mean by "block scope"
Mårten Hildell
@MartenH

@9214 I used the /local in a block and thought it would be the same thing as in C, but it
has function scope and not block scope....

In C this would be:

if( ..) {
   uint32_t hello;
   hello = 1;
}

hello variable would only live in the if block.

Vladimir Vasilyev
@9214
@MartenH I dont' know C that much, but here's the thing - C has lexical scoping, but Red has no scopes at all
Nenad Rakocevic
@dockimbel
@MartenH I strongly suggest reading the Rebol/Core Manual, if you haven't done so yet. You cannot understand Red language from R/S documentation.
Mårten Hildell
@MartenH
The page @dander refers seems to be this, https://en.wikibooks.org/wiki/Rebol_programming/Advanced/Bindology, but it's beyond me at this point
@dockimbel Thanks.... I'm reading there now also.
Vladimir Vasilyev
@9214
here's how you can "localize" the block
>> my-block: [x: 1]
== [x: 1]
>> context my-block
== make object! [
    x: 1
]
>> x
*** Script Error: x has no value
*** Where: catch
*** Stack:
Vladimir Vasilyev
@9214
@dockimbel is it correct to say that only some (or all?) any-function!s are context constructors?
and what's the difference between action!, routine! and native! ?
Nenad Rakocevic
@dockimbel
@9214 That statement is only valid for function! constructors, the other ones are written in R/S, so they don't need a Red context! to operate.
Vladimir Vasilyev
@9214
@dockimbel thanks, though context! is a hidden internal datatype, right?
Nenad Rakocevic
@dockimbel
action! are datatypes "methods", native! are just core functions written in R/S (for performance, simplicity or feasability reasons). routine! are user-written functions with a R/S body (routines exist both in Red and R/S realms at the same time).
Correct, it's not directly exposed to Red level. Though object! and function! both hold a reference to context! values internally.
Vladimir Vasilyev
@9214
I feel a strong itch to dive lower and study system programming either with Forth or R/S :smile:, any suggestions (books/stuff, meditation techniques, etc) taking into account that I only barely know C (~ first 4 K&R chapters)?
Vladimir Vasilyev
@9214
@dockimbel this means that make (action!) isn't context constructor? I mean, not in general, but when it comes to function! and object!.
Nenad Rakocevic
@dockimbel
@9214 Only in those two cases (for now), yes.
Vladimir Vasilyev
@9214

for now

:suspect:

Gregg Irwin
@greggirwin
@RnBrgn, It's possible that Red could provide more information. I can't speak to internal details, but consider that there may be a lot of overhead in tracking things. Only in the simplest cases is your code a single level series of values. Add to that, the ability to dynamically construct and change code, even at runtime, and Red potentially has to maintain a lot of state-location references.
So the question to ask may not be "Can we show line numbers?", but "What is the most helpful information to show, that is also useful when building tools?"
Greg T
@gltewalt
If we had the ability to grab a name from its value, could tell what word error happened at?
Gregg Irwin
@greggirwin
More than one word can refer to the same value. And, again, what do you do when things change dynamically? Yes, we have a lot of cases where that doesn't happen, but if we momentarily forget how things work in other langs, and think in terms of Red...if you were the "Red engine", what would you tell the user?
Greg T
@gltewalt
In this example, does 'a get clobbered twice, or are these actually distinct atoms?
>> set/only [a a a] [1 2 3]
== [1 2 3]