World: r3wp
[Core] Discuss core issues
older newer | first last |
[unknown: 5] 21-Jun-2008 [10695] | can you just get around the problem by setting a: next a ? |
Henrik 21-Jun-2008 [10696] | yes. that's janitoring of the index, which could be prone to bugs, etc. |
[unknown: 5] 21-Jun-2008 [10697] | yeah you'll definately have to be more judicial with your code but I'm thinking that the mechanics of it is the way it is intended to operate. |
Henrik 21-Jun-2008 [10698x2] | yes, it is. it would be too hard to track from inside rebol when an index should move. |
(but if it were possible, some code would be greatly simplified) | |
Dockimbel 21-Jun-2008 [10700] | >> a: make list! [1 2 3 4 5] == make list! [1 2 3 4 5] >> b: at a 3 == make list! [3 4 5] >> a == make list! [1 2 3 4 5] >> b == make list! [3 4 5] >> remove a == make list! [2 3 4 5] >> b == make list! [3 4 5] |
[unknown: 5] 21-Jun-2008 [10701x6] | Let's talk memory... |
I that in the following the 10 represents 10 "bytes"? a: make string! 10 | |
So how to we define those things in a block? | |
I know we can initilize the block with for example: a: make block! 10 But how do we determine what is in the block comprises a byte? | |
I know that in a string each character represents a byte but even then how much overhead is allocated merely by a: make string! 0? | |
These are the kinda things I wish Carl would go over so we can best optimize our use of memory. | |
Henrik 22-Jun-2008 [10707] | interesting, dockimbel. thanks. |
PeterWood 22-Jun-2008 [10708] | There is a lot of information about Rebol's memory usage in the mailing list archive. You culd start here: http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-topic-index.r?i=memory |
[unknown: 5] 23-Jun-2008 [10709x4] | I have reassociated my scripts in windows with the new 2.7.6 core but I now get an error whenever I attempt to open them which is: ** Access Error: Cannot open /C/Documents ** Near: do/args script system/script/args Any ideas? |
It appears to see a broken path and sees the rest of the path as an argument. Not sure where it is checking yet to get this information. | |
Fixed it. | |
I went into the registry and found the reference to rebview and deleted its registry keys and reassociated the .r extension with the rebol/view 2.7.6 product. | |
Chris 28-Jun-2008 [10713x2] | ; request for comments -- assert-all: func [cases [block!] /local value][ until [ set [value cases] do/next cases unless value cases/1 cases: next cases any [not value tail? cases] ] value ] |
Usage: assert-all [ a < 10 [print "a is more than 10"] a > 0 [print "a is less than 0"] ] It's the opposite of 'case really. If any of the cases are false, the related block is evaluated and the function returns none/false. If all cases are true, it returns the value of the last successful case. | |
[unknown: 5] 28-Jun-2008 [10715] | Why would we need that as opposed to just changing the current evaluation of existing case? |
Henrik 28-Jun-2008 [10716x2] | I would like to see a good implementation of a function that performs a sequence of code blocks. If a code block is good, the next one is run. If the code block causes an error, a secondary code block that is either generic for all code blocks or specific to that particular code block is run. I'm thinking step-by-step code that either runs successfully or causes a generic or specific error. I don't know if it makes sense to do that, but I sometimes miss that if I need to do something with user friendly network connectivity. |
although I've recently switched to state machines for that kind of code. | |
Graham 28-Jun-2008 [10718] | all-nots ? |
Chris 28-Jun-2008 [10719x2] | Paul: it's a common enough pattern, I'd like to find the most appropriate way to express it. Actually, that's the principle behind QM (which of course, this is intended for). The alternative case above would be: case [ not a < 10 [print "a is more than 10"] not result: a > 0 [print "a is less than 0"] ] result Requires a 'not statement for each test, requires an extra word to track the result and does not return a meaningful value. Consider this: if assert-all [ user/has-role? 'editor [make error! "You do not have required permission"] article: get-param 'article [redirect-to %/articles/create] 10'000 < length? article [make error! "Article is too long"] ][ save %article.txt article redirect-to %/articles/list ] |
Henrik, how does your scenario differ? Do you have a sample of your solution at work? | |
Henrik 28-Jun-2008 [10721] | I had a function that does this a while ago, but I have to dig it up |
Chris 28-Jun-2008 [10722x3] | Graham, I'm still pondering naming. 'assert seems to evoke unit tests, that's not what this is. 'all-nots doesn't quite get the essence either. 'all-else is a possibility? Until then, I still lean toward 'assert-all. |
H: is this the type of problem you were addressing? | |
That is, I have a series of tests, each requiring a case for failure... | |
Henrik 28-Jun-2008 [10725] | Chris, I guess it could work. |
Chris 28-Jun-2008 [10726] | I'm curious re. approach, expression and naming... |
Henrik 28-Jun-2008 [10727x2] | found it, but I remember it being more elegant than the code I found here... |
sorry, it does not work very well. I think I would build a new one from scratch if I needed it again. | |
Chris 28-Jun-2008 [10729] | I get that -- a sign of personal progress, perhaps? |
Henrik 28-Jun-2008 [10730] | well, I tried a single line of code with it, and it didn't do what I wanted. I guess I could ask myself if I would write that kind of code today. :-) |
[unknown: 5] 28-Jun-2008 [10731] | Chris - 'case is native so even adding a 'not statement is going to be faster solution I think. |
Graham 28-Jun-2008 [10732x2] | Should one go for speed or readability? |
If it's a time critical app like a web server I'd go for speed ... | |
Chris 28-Jun-2008 [10734x3] | Readability. I want it to be fast, of course, but long-term it's not worth the compromise. I want to do more with less. |
Indeed 'all would be fastest yet, except you don't get feedback at the point of failure. | |
You could use 'foreach which'd be fast, but then you'd have to block! your case as well as your fallback losing readability. | |
Janeks 30-Jun-2008 [10737] | I am working on sript, that composes and sends html e-mail. It is rather simple, but now I would like that e-mail will contain inline images. I found out that they are multipart messages, and that image is referenced with cid in html image and in image part it is marked as Content-ID: </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3D"Courier New" size=3D2></FONT><IMG height=3D47=20 src=3D"cid:26DB76551F2E4591BBC3B599C3A7CCAE" width=3D320></DIV> <DIV><FONT face=3D"Courier New" size=3D2></FONT> </DIV> </BODY></HTML> ------=_NextPart_001_00A9_01C8DAAB.A817E460-- ------=_NextPart_000_00A8_01C8DAAB.A817E460 Content-Type: image/bmp; name="ML.bmp" Content-Transfer-Encoding: base64 Content-ID: <26DB76551F2E4591BBC3B599C3A7CCAE> Qk22vQEAAAAAADYAAAAoAAAADwIAAEgAAAABABgAAAAAAIC9AQDEDgAAxA4AAAAAAAAAAAAA//// //////////////////////////////////////////////////////////////////////////// How to implement such html e-mail generation in rebol script? |
Graham 30-Jun-2008 [10738] | the send/attach can generate the multipart components for you. |
Janeks 30-Jun-2008 [10739] | O'k. But how to put Content -ID into message part? |
Gregg 30-Jun-2008 [10740] | Alan Dechert <[dechert-:-gmail-:-com]> asked the same thing on the ML earlier this month. Maybe the two of you can collaborate on a solution. If you could enhance SEND to allow it, maybe with a new refinement, we can try to get Carl to make it the standard. |
Graham 1-Jul-2008 [10741x3] | Anyone know how to use sort on some data where eg. skip value is 10 and you want to sort of anything but the first element? |
Looks like the comparator function takes two arguments ... which are the first of each set | |
Ok, sussed it out .. the compare can be an integer offset | |
Janeks 2-Jul-2008 [10744] | What is the right way to check is port (ODBC, mySQL) open? Is it a-port/port-id ? |
older newer | first last |