Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
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
Vladimir Vasilyev
@9214
What you have inside block are words, not datatypes
but you're switching by datatype
BeardPower
@BeardPower
@9214 word
Vladimir Vasilyev
@9214
You can use construction syntax instead, that way block will contain a datatype, not a word that looks like datatype:
>> switch 'word! [word! [print "word!"]]
word!
>> switch word! [#[word!] [print "word!"]]
word!
Toomas Vooglaid
@toomasv
@lepinekong_twitter
Tortured
switch type compose [(word!) [print "word!"]]
== word!
lepinekong
@lepinekong_twitter
@9214 ah ok thanks I like 'word! better
Vladimir Vasilyev
@9214
lepinekong
@lepinekong_twitter
@toomasv too much :smile:
BeardPower
@BeardPower
@9214 That's RDM for the new century :)
Vladimir Vasilyev
@9214
>> word? 'bird!
== true
BeardPower
@BeardPower
I expect some new interpretation from you soon: The Red is a lang! :)
nedzadarek
@nedzadarek
Can we make a wiki that contains links to parse's stuffs?
and they are already covered here, so I don't see a need in another collection of links
nedzadarek
@nedzadarek
@9214 but are there some difference between Red's and Rebol 2 & Rebol 3 's parse?
ps. that I cannot think because I sing the song!
Vladimir Vasilyev
@9214
@nedzadarek Red's parse is more sophisticated than R2 version, but on a par with R3, I guess.
nedzadarek
@nedzadarek
Then I would like to keep such informations... if possible.
Vladimir Vasilyev
@9214
@nedzadarek you don't need to ask for permission to start a wiki page, if that's what you mean.
nedzadarek
@nedzadarek
That's good to know! Thank you.
Gregg Irwin
@greggirwin

@lepinekong_twitter, at this stage in your Red career, if someone offers a hint, clue, or suggestion in answer to a question or problem you pose, please take some time to understand their response, rather than immediately saying "Why would I need to...?"

Do you understand the behavior now? If not, does this help?

type: word!
blk: [
    unset! [
        print "unset!"
    ] 
    word! string! file! url! block! [
        print "word! string! file! url! block!"
    ]
]
switch type blk

find blk type

type? type
find blk type? type

type? first blk
find blk 'word!

switch type reduce blk

There should be no more explanation needed than this, and is an example of how to go about learning and debugging on your own.

Before pasting the entire thing into a console, see if you can predict what each result will be, then add the next statement. If the result isn't what you expected, think about it and see if the result makes sense.
PeterWAWood
@PeterWAWood
Please could somebody who has compiled, installed and run the Android example take a look at this ML message and see if they can help the young poster.
Vladimir Vasilyev
@9214
@PeterWAWood he needs latest Red sources from Android branch for that, which is private ATM.
Vladimir Vasilyev
@9214
That is - no one but @dockimbel compiled it (and he shared an APK here for inter-community testing purposes), others should wait for 0.7.1 milestone with full Android support.
PeterWAWood
@PeterWAWood
@9214 Thanks. I've let the youngster know.
lepinekong
@lepinekong_twitter
@greggirwin sorry but red is supposed to be simple but as for type testing it's a headache compared to other languages.
Vladimir Vasilyev
@9214
@lepinekong_twitter maybe it's because you haven't learned the fundamentals?
which you supposed to do if you want to be proficient in the language.
Vladimir Vasilyev
@9214
I bet "other languages" don't have 47 (and counting) built-in datatypes ;)
BeardPower
@BeardPower
We should aim for at least 200 ;-)
nedzadarek
@nedzadarek
@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
Vladimir Vasilyev
@9214
Everything is a quirk if you don't understand the difference between types of values.
Nenad Rakocevic
@dockimbel

@nedzadarek

>> 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.

Vladimir Vasilyev
@9214
>> equal? type? first [integer!] type? 'integer!
== true
>> equal? type? first [#[integer!]] type? integer!
== true
nedzadarek
@nedzadarek
@9214 @dockimbel I mean quirks in non-tech way. You see something that looks like, for example, datatype! but it is word!
Vladimir Vasilyev
@9214
@nedzadarek integer! is a word bound to datatype value.
nedzadarek
@nedzadarek
@9214 yes... but pi: 3.14 is the same, "word bound to float value". For simplicity "a float".
Vladimir Vasilyev
@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
nedzadarek
@nedzadarek

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.

Vladimir Vasilyev
@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.
nedzadarek
@nedzadarek

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?