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
nedzadarek
@nedzadarek
@toomasv foreach idea is interesting. We can add resize flag and we can almost call it "responsive design".
Toomas Vooglaid
@toomasv
Yeah, if you make base faces responsive to window size, why not.
nedzadarek
@nedzadarek
Well, thank you.
Toomas Vooglaid
@toomasv
:smile:
Ungaretti
@Ungaretti
What does parse's if statement do? It seems it just exit the parsing process if the result is false or none. There is no if-this-do-that? Red blog says it "backtracks", what is that?
Boleslav Březovský
@rebolek
@Ungaretti it works like if-this-do-that. If the condition is true, parse rule continues:
>> block: [1 2]
== [1 2]
>> parse block [set value integer! if (value = 1) to end]
== true
>> block: [2 2]
== [2 2]
>> parse block [set value integer! if (value = 1) to end]
== false
Gabriele Santilli
@giesse
@Ungaretti you would use it with | to implement an if/else scenario. eg. some-rule if (condition) true-rule | false-rule
Ungaretti
@Ungaretti
@giesse & @rebolek Thank you! I could not find an example anywhere.
Ungaretti
@Ungaretti
Sorry for being insistent but, so, if not used with the true-rule | false rule, it just exits the parse returning false if it's condition is false?
Vladimir Vasilyev
@9214
@Ungaretti if expression in parentheses evaluates to false or none, then Parse backtracks and tries to apply the next alternate rule. If there's no such rule, it will fail.
Ungaretti
@Ungaretti
@9214 by alternate rule you mean something with this | that? What exactly means "backtrack"?
Bactrack means try the same input again, right?
Vladimir Vasilyev
@9214
Yes, alternate rule is anything past |. "To backtrack" means to restore input position prior to invocation of a failed rule.
Ungaretti
@Ungaretti
@9214 Thanks!
Vladimir Vasilyev
@9214
Note that only input position is backtracked, whatever changes were applied in that failed rule will remain.
nedzadarek
@nedzadarek
@dsunanda rebol does the same - y is not resized.
Ungaretti
@Ungaretti

I'm resuming my documentation of Red at helpin.red , and working on the parse chapters. There is a lot to be done there.
Since I can't find information about many keywords, I'm learning by trial-and-error, but I stumble on some inexplicable behaviours, for example: Red blog says that break should "break out of a matching loop, returning success". I try it but it returns false (failure?):

block: [1 2 3 4]
print parse block  [
    integer! (print 1)
    integer! (print 2)
    break
    integer! (print 3)
    integer! (print 4)
]
1
2
false

It seems to me as the same as ´fail´ or ´reject´. How come?
I think I have checked all the available online documentation. Is there any hidden or unknown document that explain parse's keywords?

dsunanda
@dsunanda
Latest build does not seem much different with SIZE-TEXT
Vladimir Vasilyev
@9214
@Ungaretti red/red#3478
dsunanda
@dsunanda

layout compose [tb: box (mold system)]
length? tb/text
== 668501
size-text tb
== 159x17

In R2:
size-text tb
== 97x49436062

Vladimir Vasilyev
@9214
@Ungaretti and what do you expect, if I may ask?
break breaks the outer loop, that's it.
nedzadarek
@nedzadarek
@dsunanda you cannot compare system from both languages and I think they have different default font size.
dsunanda
@dsunanda
I appreciate that - it was just a way to get a large text object. But there is no way ANY of the Red SIZE-TEXT values I am seeing are accurate or useful.
nedzadarek
@nedzadarek
@dsunanda I do not see any difference in how precise it is.
Red:
Red for Windows version 0.6.3 built 26-Mar-2018/1:14:22+02:00
Rebol:
REBOL/View 2.7.8.3.1 1-Jan-2011
Vladimir Vasilyev
@9214
size-text should return width/height of area which can wrap the text in a face. This is clearly not the case here, even with wrap option:
view [text 100x100 gray wrap "a  b  c^/b^/c" [face/size: size-text face]]
Ungaretti
@Ungaretti
@9214 I can't thank you enough for all your help.
So a "matching loop" is one of any, some and while. That is the information I was missing. I thought of a "matching loop" as the parsing itself. It is a matching loop after all. Hence my surprise when a parse with break returned false.
dsunanda
@dsunanda
One of these two SIZE-TEXTs is from R2 - and is useful. The other is from Red and is not:

layout [tb: box wrap 10x1000 ". . . . . . . . ."]

size-text tb
== 6x171
== 51x15

Vladimir Vasilyev
@9214
@Ungaretti this ticket was a subject to a hot design debate some time ago, so I suggest you to use this info, but to provide a "caveat emptor" for readers, as this behavior can change, and probably is not an intended one as it is now.
Boleslav Březovský
@rebolek
@dsunanda I agree, it must be bug IMO
Vladimir Vasilyev
@9214
Looks like Red version doesn't account for newlines.
dsunanda
@dsunanda
Thanks guys. SIZE-TEXT is extremely useful in R2 apps for resizing / re-offsetting boxes to close-up gaps in paragraphs (and other uses). If we can get to be to as good in Red, I'd be very happy :)
Vladimir Vasilyev
@9214
@dsunanda I guess you can file a ticket for that, and show some examples of actual / expected behavior.
dsunanda
@dsunanda
Cool, thanks. Will do Vladimir
Gregg Irwin
@greggirwin
@Ungaretti , @9214 has some parse docs in the works as well, though we've pressed him to do some other things lately.
Vladimir Vasilyev
@9214
@greggirwin I don't really have any, besides a couple of rough drafts and keywords listing.
Gregg Irwin
@greggirwin
Ah, OK. I imagine there's a lot in your head though. :^)
Ungaretti
@Ungaretti
@greggirwin @9214 I would love to see those docs, although I believe their may be aimed at more experienced programmers. There is a serious lack of information about parse for beginners, and I hope I can improve that somewhat.
Correcting myself: there is a serious lack of information about parse. Period.
Gregg Irwin
@greggirwin
Fortunately, we have some parse gurus in our community. Once we have a good start on content, it will be vetted heavily for accuracy and usefulness. So we'll have specs, user guis, and helpin-Red among others all working together to make it accessible.
nedzadarek
@nedzadarek
@Ungaretti parse introduction article has a lot of informations.
There are many tutorials for the Rebol like this. They are good but they might not work in the Red in 100% of cases.
What we need is a catalogue of examples (snippets). We need to have an ability to look for certain phrase or word (search engine). We need to know pros, cons and comparison of different techniques.
Vladimir Vasilyev
@9214
@nedzadarek Parse has a wide range of applications, from simple text processing to metaprogramming and compiler frontend construction, so there's a lot of ground to cover. Catalogue of text search and processing patterns - okay, but explaining how to build a compiler / interpreter, and comparing different approaches to construction of DSLs and general-purpose languages (which are always task and application specific) isn't that trivial.
Ungaretti
@Ungaretti
@nedzadarek My intention is to improve the examples given for each keyword and add snippets. I also want to add three chapters: "Parse usage- Validate inputs", "Parse usage- Extracting data from text" and "Parse usage - Manipulating text", with examples for each (other suggestions welcome). Hopefully that will be enough to get a beginner going with parse.
Currently the website has 11 parse links , including the ones you mention. The current doc, not online yet, has 15, but among them I could not find a simple good example for the if keyword, for example. I got examples for that today here at gitter, btw.
nedzadarek
@nedzadarek
@9214 yes, for bigger things it's better to write a bigger article.
@Ungaretti Certain feature lacks official documentation. Some feature require you to know some terms. I agree - it's not always beginner-friendly. Good luck documenting this 3 chapters. As I tried I know that extracting might be a lot harder/different. Manipulating series might be dangerous so I would say it's "advanced" (beginner+) level.
ps. you can manipulate any series, not only text.
Palaing
@Palaing

What is the right way to refresh text-list face?

mylist: ["one" "two" "three"]
view [text-list data mylist [
    change at face/data face/selected "hi there"
]]                ; text-list is not updated when clicked
print mylist    ; though underlying list is

It does not work better if I add show face
But strangely it works with face/data: face/data:

mylist: ["one" "two" "three"]
view [text-list data mylist [
    change at face/data face/selected "hi there"
    face/data: face/data
]]                ; now text-list is updated when clicked
Semseddin Moldibi
@endo64
Cannot test as I am on mobile, but probably it works because of reactivity that face/data: triggers. you can set a word to your text-list and then examine by probing.
Not sure why it doesn't work with show though.
Palaing
@Palaing
@endo64 actually - my mistake - it does work with show in this example
Palaing
@Palaing

@endo64 it did not in this situation - with a request-text function similar to Rebol's:

view [text-list data mylist [n: face/selected request-text/default face/data/:n show face]]

(face is not updated though mylist has been changed)