## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
• Oct 20 2019 22:59
@dockimbel banned @SmackMacDougal
• Dec 03 2017 05:53
@PeterWAWood banned @matrixbot
• Sep 28 2016 12:19
@PeterWAWood banned @TimeSeriesLord
• Aug 13 2016 03:23
@PeterWAWood banned @Vexercizer
@lepinekong_twitter @9214 Red has some quirks like (type? first [integer!]) = (type? integer!) but the language is more or less fair/concise when you learn some "weird stuffs" (like only word/refinement used in append or parse's change).
ps. most language have quirks
@9214
Everything is a quirk if you don't understand the difference between types of values.
@dockimbel

>> type? first [integer!]
== word!
>> type? integer!
== datatype!

In the first case, the word inside the block is not evaluated (because nothing causes it to be evaluated), in the second case, the word is the argument of a function, so it gets evaluated (it evaluates to a datatype!) . No quirks here, just basic evaluation rules of the language. Once we get syntax coloring in the console, it should be easier to spot the difference between values of different types having same literal form.

@9214
>> equal? type? first [integer!] type? 'integer!
== true
>> equal? type? first [#[integer!]] type? integer!
== true
@9214 @dockimbel I mean quirks in non-tech way. You see something that looks like, for example, datatype! but it is word!
@9214
@nedzadarek integer! is a word bound to datatype value.
@9214 yes... but pi: 3.14 is the same, "word bound to float value". For simplicity "a float".
@9214
Except that word is not a float, it's a separate entity which can refer to other values, including floats.
Yours and @lepinekong_twitter's confusion boils down to
>> foo: 'bar
== bar
>> 'foo = foo
== false

Except that word is not a float, it's a separate entity which can refer to other values, including floats.

You are right. However Red users prefers to use X! as to say "it's a word containing datatype". We can use pi!: 42 but it breaks conventions.

'foo looks different than foo. I may be biased but foo looks like variable in most language (or some variable-like thing in language that doesn't like mutations). 'foo looks like some kind of symbol or something. So I would assume that you are comparing some value 'foo with variable foo.

@9214
You're comparing two evaluation results - leftmost is lit-word! that evaluates to word!, and rightmost word! which evaluates to bound value. Somehow you expect the two to be equal (it can be if foo is bound to word! foo).
>> foo: 'foo
== foo
>> 'foo = foo
== true
Your "I guess" and "it looks like" with "I would assume" makes me think that we're on some kind of quiz game. Every programming language have evaluation rules, and Red too. Once you learn them, there's no place for "guessing" and "assuming".

Because, following your "oh it looks like X so it should be X" logic, this:

(((,[:+/_2&{.)@](^:(2-~[)))&1 1)

is a, well, regex, I guess.

while in fact it's a Fibonacci sequence function.

Once you learn them, there's no place for "guessing" and "assuming".

Yes but some features of a language are more obvious than others.

Because, following your "oh it looks like X so it should be X" logic, this:

(((,[:+/_2&{.)@](^:(2-~[)))&1 1)

is a, well, regex, I guess.
while in fact it's a Fibonacci sequence function.

Forth or some similar language?

@9214
No, it doesn't even look like Forth. It's J. They both encourage tacit programming though. :)
@9214 yeah, tacit programming and people mention forth here so I assumed that's Forth:D
btw. are you J programmer?
@9214
I've yet to see a language where some feature is obvious from the start.
@9214 but when you programmed in a few languages then some features are "obvious", like most languages have some kind of simple container, Ruby/C/... have arrays [1, 2, 3], Lisp has lists (1 2 3), Lua has tables {1 2 3}.
JacobGood1
@JacobGood1
red has... blocks?
@9214
I tend to not borrow baggage from other languages when I learn a new one. Your Lisp list is an s-expression though, and an incorrect one (1 is not a function).
JacobGood1
@JacobGood1
unless it was passed to a macro or if it was preprocessed =)
^^ yes, it should be with something like this, afair '(1 2 3)
@9214
That's what I'm saying - you either learn the rules as they are or live with your assumptions (that (1 2 3) is a list and foo is a variable) until they hit you in the back.
@JacobGood1 yes, red has blocks and they are similar to Lisp's/Lua's in that they can contain values with different types.
@9214 Yes, we should learn the rules (I don't deny it) but we take some "informations" from other languages that we have learned. In my opinion, a good way to learn is by mistakes. When you get some error when you try compare integer! with first [integer!] then you have "eureka moment" - ah, it's different, I should test/ask about it. I learn faster that way.
@9214
@nedzadarek learning by mistakes is one thing, but claiming that "oh it's bad it's not like in other languages I'm confused it's hard not hot" like some people do, is another.
@9214 I'm not saying it's super bad/hard. It's just not super obvious like other language features: parse [1] [integer!]
ps. and I love learning new languages so... I'm not that kind of person.
@9214
@nedzadarek "super obvious" is a weak metric. It was super obvious to me from the get-go that I can do interesting things with blocks and words, while for some other people it's a complete mystery, and they still use Red as "oh it's just a usual scripting language with variables and arrays).
Gregg Irwin
@greggirwin

sorry but red is supposed to be simple but as for type testing it's a headache compared to other languages.

I mean quirks in non-tech way. You see something that looks like, for example, datatype! but it is word!

@lepinekong_twitter @nedzadarek , it's not like other languages. You can't treat it as such in all cases. Sometimes, yes, because it does its best to help you and provide familiar affordances for your comfort. :^) Much of the time, things work as you might expect. You see words, but "get" values because they're evaluated. But you do have to be aware of when evaluation occurs at times. Simple appearances can be deceiving, but nobody has yet offered a better solution.

However Red users prefers to use X! as to say "it's a word containing datatype".

We try to gently encourage people to say words "refer to" values, but it's not always as comfortable as "X is 4" or "X is an integer".

but when you programmed in a few languages then some features are "obvious", like most languages have some kind of simple container, Ruby/C/... have arrays [1, 2, 3], Lisp has lists (1 2 3), Lua has tables {1 2 3}.

And do you treat all those things equally, expecting them to work the same? Do you add and remove items in the same way? Can you add and remove items? Are there varying performance implications? Named access to values?

Red works as intended and by design. It's not for everybody though. For those who feel it should work like other languages...there are other languages, and that's fine. But Red is not wrong. Red, bugs aside, can't be wrong. It is just Red. It may change and evolve, of course, but before suggesting changes we have to understand why it is the way it is.

@9214 of course it's subjective. We could have different background. I tried Rebol and Lua so I knew about "block magic" too. C user might get confused by some parts.

I have been thinking about changeing value with parse.
I have such code:

rule: ["bcd" keep ("dcb")]
parse bl: "abcd" [#"a" change collect set s [rule] (s/1)] bl

I want to "return" some value from the ruleand change original series (bl in this case) with the value "returned" from the rule.
What do you think about such code? Can it be done better?

Boleslav Březovský
@rebolek
@nedzadarek Lua's table is certainly not a simple container type like C's array.

@greggirwin

And do you treat all those things equally, expecting them to work the same? Do you add and remove items in the same way? Can you add and remove items? Are there varying performance implications? Named access to values?

I don't treat them equally (in 100%) but I think most general purpose languages share some operations (or there is a way to do it). Ruby arr.push(5) #=> [1, 2, 3, 4, 5] Lua table.insert(arr, 5). Of course there are some some differences but in the end I have container with 1 more element.

...there are other languages, and that's fine.

There are always macros/pre-load, DSLs etc. This language is very customizable.

redredwine
@redredwine

I am trying to play with parse to extract some information from some log files, but cannot figure out how to .
Let's say I am trying to extract the transaction id, the description and the startTime and the endTime, how do I do that. the log file has the following data:-

tid=93129247. PROCESSA Authorization Verification Starting. startTime: 2016-06-03 11:27:42.434, "
tid=3129247. System B call begin. startTime: 2016-06-03 11:27:42.435, "
tid=129247. From System B :soapenv:Client.Failure authorization failure in method authorize. startTime: 2016-06-03 11:27:42.435, endTime: 2016-06-03 11:27:42.510, "
tid=9247. System C Authorization Failed. startTime: 2016-06-03 11:27:42.434, endTime: 2016-06-03 11:27:42.510, "

it would also be good to have a column to display the difference between the startTime and the endTime

@9214
probe get also 'x probe parse x: "abc" [
collect [
to change keep "bc" [2 3] to end
]
]
@9214
@redredwine
log: next {
tid=93129247. PROCESSA Authorization Verification Starting. startTime: 2016-06-03 11:27:42.434, "
tid=3129247. System B call begin. startTime: 2016-06-03 11:27:42.435, "
tid=129247. From System B :soapenv:Client.Failure authorization failure in method authorize. startTime: 2016-06-03 11:27:42.435, endTime: 2016-06-03 11:27:42.510, "
tid=9247. System C Authorization Failed. startTime: 2016-06-03 11:27:42.434, endTime: 2016-06-03 11:27:42.510, "
}

line: [
"tid="
keep to dot 2 skip
keep to ". startTime:" thru ["startTime:" space]
keep to comma 2 skip
["endTime:" space keep to comma | keep (none)]
thru newline
]

data: parse log [collect some line]
Extracted raw data then can be trivially preprocessed whichever way you want (conversion of id to integers or starting/ending time to date! (you'll need first to replace space with / for that, then load, etc). Just take 4 elements at a time (they're all strings, except for non-existent endTime in some cases, which I substituted with none).
hiiamboris
@hiiamboris
what is the rationale behind pair comparison as y before x?
https://github.com/red/red/blob/master/runtime/datatypes/pair.reds#L308
where does it make sense to compare like this? sorting?
@9214 thank you for the answer.
I know that I have to go to the pattern (e.g. to change...) and skip rest (e.g. to end) but what is better with you approach? I want to know + and -.
@9214
@nedzadarek + and - of what? It's the same approach as yours, just refactored.
I see.
Gregg Irwin
@greggirwin
:point_up: April 9, 2018 3:30 AM Inherited from Rebol. Is there a good reason to change it?
Let me see if I have any notes on other reasons.
Gregg Irwin
@greggirwin
@hiiamboris, I can only find the Rebol note that says " This is preferred to support the y sorting used by various graphics algorithms." Would be good to have concrete examples for that.
hiiamboris
@hiiamboris
@greggirwin I was just curious
I find that most operations on pairs are either akin to what within? does or just flavors of a = min a b or all [a/x > b/x a/y > b/y]
which I don't think we can do (or can we?) with simple comparisons as this way any [a <= b a > b] won't always hold true anymore
current behavior on the other hand reminds me of scan line ordering, and if it can be relied upon (can it?) I think some not so strict a/y < b/y tests can be replaced with a < b for conciseness, which is esp. handy if a or b is a function (less trouble with refinement handling as /y is a refinement in that case) or an immediate expression
Gregg Irwin
@greggirwin
Sorting has a lot of subtleties in Red, as sorting a block containing different types works, and you need to consider the inherent type priority.