r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

Maxim
9-Nov-2006
[6164x2]
pekr:  its actually a word pointer  and  MS example look like so:
GetUserName( infoBuf, &bufCharCount )
which is why I supplied a string, so that the get user name would 
receive a pointer instead of a number.
Pekr
9-Nov-2006
[6166]
pointer is a number
Maxim
9-Nov-2006
[6167]
&bufCharCount  asks to get the pointer to the word, not the value 
of the word... no?
Pekr
9-Nov-2006
[6168x2]
what about trying putting struct instead of buffer [char] in there? 
:-), with first element being a string? Struct itself will be represented 
as a pointer
well, maybe better wait for someone like Ladislav or Anton or Gabriele 
or anyone else more experience than me. I always work by guess, try, 
change aproach, till it works (or it does not :-))
Maxim
9-Nov-2006
[6170]
just one question, how many bytes is a double word (in MS) supposed 
to have 4 or 8?
Pekr
9-Nov-2006
[6171x3]
16?
sorry, mixed bytes and bits :-)
bit, byte=8bit, nibble=4bit, word=32bit=4bytes, double=64bit=8bytes?
Maxim
9-Nov-2006
[6174]
k thanks, just wanted to confirm.. I've just not been thinking in 
those terms for soo long.
Pekr
9-Nov-2006
[6175x2]
my friend suggests me, that it can't be said - it depends upon platform. 
Typically it is good to use sizeo(word) to get the idea ...
sizeof
Maxim
9-Nov-2006
[6177]
I think that is more a problem with the use of int and long.
Pekr
9-Nov-2006
[6178]
try wikipedia - some good entries there ...
Maxim
9-Nov-2006
[6179x2]
but... anyhow... thanks... by chatting with you I realized why my 
string was staying at 0 length, while its actually filled with the 
data.
yesss... I do more and more... computer sciences are very well explained 
on it.
Pekr
9-Nov-2006
[6181]
so what actuall you realized?
Maxim
9-Nov-2006
[6182x6]
string! have an internal size and an external size.  using a string 
within rebol, will always update the size, so that it returns the 
current amount of the string! which has been "filled"
which is why 
>>  make string 100
== {}
internally, its 100 bytes long, but externally, it hasn't been filled 
so its still length? 0
now the external call dumps chars directly in the string and add 
a null termination.
but obviously, since REBOL didn't fill it... it still thinks it length? 
0  ... but its internal buffer really does contain data!
so prefilling the string to 100 chars of anything, will at least 
allow you to acces the whole buffer afterwards...
Pekr
9-Nov-2006
[6188x2]
there are two cases - when external function returns string and expects 
your struct for it, and second, when external function allocates 
its own buffer and provides you with a pointer
that is strange a bit then .... feels like close to cause a crash 
:-)
Maxim
9-Nov-2006
[6190x3]
yep, but in a case where rebol returns the value, its smart enough 
to look it up and find the null terminator for you  :-)
and adjust the external size counter.
in this case, rebol never really manipulates the string...
Pekr
9-Nov-2006
[6193]
well, that's true - doing make string! 100 does not mean length? 
should return 100 .... maybe we should have size-of?
Maxim
9-Nov-2006
[6194x2]
all I need to do is :
value: copy/part  buf  find  buf  #"^@"
good idea!
Pekr
9-Nov-2006
[6196]
wouldn't it be enought to just value: copy buff?
Maxim
9-Nov-2006
[6197]
hum... nope, tried it, it copies the whole string past the terminator... 
and it actually should, otherwise we could not parse binary data...
Ladislav
9-Nov-2006
[6198]
Max: to-logic "false" how about using something like to-logic "1 
+ 3 < 2" then?
Maxim
9-Nov-2006
[6199]
I know we have to draw a line... but true and false literal string 
representations of boolean values... should be a valid representation 
of input just just like literal integer, decimal, dates, urls, files, 
issues, words, etc values .  no?


we already accept 0 and 1,  why not the string equivalent (obviously 
also support on, off)

LOAD and DO are a more flexible second level.
Ladislav
9-Nov-2006
[6200x2]
Note: TO LOGIC! is compatible with IF in cases like:

if "false" [...]
if to logic! "false" [...]

except for one case: to logic! 0 yields FALSE
another example: to logic! 'false
Maxim
9-Nov-2006
[6202]
oh this last one is a bit dangerous IMHO.


since not using the /all refinement of mold easily create true/false 
words... (I  know you'll say use /all) but REBOL isn't always the 
data originator.
Gregg
9-Nov-2006
[6203x3]
Anytime you pass a string buffer to the API, you have to pre-fill 
it. I have a little func called NULL-BUFF, that just inits a string 
filled with nulls. 

A DWORD is 32 bits. A WORD is 16.
but true and false literal string representations of boolean values... 
should be a valid representation of input just just like literal 
integer, decimal, dates, urls, files, issues, words, etc values . 
 no?


Only in the case of TO LOGIC!, not as general substitutes anywhere. 
Of course, it's easy enough to patch TO-LOGIC to do that if you want.
I think I actually did that at one point, and also did a func to 
allow FORMing logic values to their alternate words (on/off, yes/no).
Maxim
9-Nov-2006
[6206x2]
I agree that its only a valid case for the TO LOGIC!
I really think we must separate general evaluation and value creation/conversion 
in our heads.
Gregg
9-Nov-2006
[6208x2]
Agreed. I'll have to look at my CAST func to see if I dealt with 
any of these issues there.
Nope. Maybe I should. :-\
Maxim
9-Nov-2006
[6210x2]
I had also done as-decimal, as-integer which had an expanded input 
format... maybe we should publish a set of functions, one for each 
datatype and submit to the community for peer review?  maybe then, 
this can find itself within R3.  if the work is all done, I don't 
see why Carl wouldn't want a consistent, and already documented set 
of functions.
and if he wants, he can just re-implement them natively, if the speed 
gains are worth it.
Gregg
9-Nov-2006
[6212]
We can publish them, sure, but I don't know if they'll get into R3.
Maxim
9-Nov-2006
[6213]
Carl is very open AFAICT.  this is specifically walking on one issue 
which needs improvement in REBOL in general.