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

World: r3wp

[World] For discussion of World language

Pekr
5-Dec-2011
[337]
Try Google "World" :-) Anyway - that's not important, it just came 
to my mind ...
Sunanda
5-Dec-2011
[338]
Can you comment on what World is doing when fed incorrect arguments? 
In these two cases below, both R2 and R3 throw an error....
       w> 1-jan-2011 xor 1-jan-2012
       == false
       w> 1-jan-2011 and 1-jan-2012
       == true
Geomol
5-Dec-2011
[339]
It relates to the true/false value of different values. Using IF, 
only logic false and none will fail the IF. All other values will 
fulfill the IF. I have brought this idea to AND, OR, XOR etc. So 
because you can write:

w> if 1-jan-2011 [true]
== true

you can also write

w> 1-jan-2011 and 1-jan-2012
== true
Sunanda
5-Dec-2011
[340]
Okay.....Yet is is confusing that bad args are caught in some cases 
but not in others:
       w> 1-jan-2012 xor 555
       == false
       w> 1-jan-2012 xor 5x5
       Valid pair: 5x5
       ** Error: xor is missing one or more arguments
       ** Near: 1-jan-2012 xor 5x5
Geomol
5-Dec-2011
[341x5]
That's because pair! isn't implemented. It's just prepared for in 
the lexer, and that's why you see the text "Valid pair: 5x5". Only 
the datatypes listed in the cortex_alpha.pdf doc enters the World 
engine, and pair! isn't among them ... yet.
In other words, the pair! is ignored at this time.
Maybe I should tell a bit, how I work, to make it easier for you 
to understand, what you've got for now. I do much of assembly line 
programming, because it reduces the time of development. So when 
I wrote the lexer, I didn't just implement e.g. numbers, because 
arithmetics would be the first functionality, I would finish. I implemented 
all 40-50 datatypes, I wanted in World, in the lexer at the same 
time. So the lexer is prepared for more datatypes, than what actually 
works for now, and you will just see "Valid <something>" from the 
lexer, when it recognizes such a type.
Like:

w> 1x2 [bob-:-server-:-com]
Valid pair: 1x2
Valid email: [bob-:-server-:-com]


Btw. date! and time! isn't well implemented for now, and I'll put 
that in the next update to README.
(Actually the lexer might just recognize around 30 datatypes, because 
some types need to be created with MAKE.)
sqlab
5-Dec-2011
[346]
Why does world open a listening socket at port 8080?
Geomol
5-Dec-2011
[347x3]
World seems to be fussy about which directory it is launched from


Is there a way to figure out, what directory a command launches from, 
which will work across platforms? I could check argv[0] in main(int 
argc, char **argv) , but that wouldn't work, if world is put in a 
bin, which is part of $PATH.
sqlab, it does by defaul?
*default
sqlab
5-Dec-2011
[350]
Sorry. it opened a listening socket at port 0.
Geomol
5-Dec-2011
[351]
What do you do to see that on your system? What os?
sqlab
5-Dec-2011
[352]
At first start on Win XP. I got a warning from the firewall.
After I checked with process explorer
Geomol
5-Dec-2011
[353x5]
Ok, under Windows, I found, I had to initialize the networking, so 
that's done at startup. (This isn't necessary under OS X and Linux.) 
You can see the code being executed in the function init_net () in 
the file src/host/win32/network.c. If you think, it should be done 
otherwise, let me know.
The file is found at
https://github.com/Geomol/World
if that wasn't clear.
Does R3 (or R2) also cause your firewall to give a warning?
Topic: Routines
I suggest expanding the make routine! spec to the following:

	routine-name: make routine! [
		"routine description"
		[special attributes]
		library
		"routine-name"
		[
			argument1 [arg1-world-type] arg1-type
			"argument description"
			argument2 [arg2-world-type] arg2-type
			"argument description"
			...
		]
		return-type return-world-type
	]


, where the following fields are optional: Routine description (string!), 
Special attributes (block!), Argument name (word!) and Argument description 
(string!).


Then good documentation can be made with HELP. Argument names are 
not really needed, as routines are compiled code in a library, but 
names can make the docs easier to understand.
Oldes
5-Dec-2011
[358]
seems to be fine... what about the return-world-type as optional?
Geomol
5-Dec-2011
[359]
And then it should try to guess it from the return-type?
Oldes
5-Dec-2011
[360]
yes
Geomol
5-Dec-2011
[361]
Ok, makes sense.
Oldes
5-Dec-2011
[362]
and maybe to make same order like for args.
Geomol
5-Dec-2011
[363x4]
Actually I had it like that at first, but I found the reverse order 
to be easier to understand. (It can be just me.) Because then I read 
a simple routine spec as: routine is in library, named "routine-name", 
take argument with world type arg1-world-type, which is converted 
to arg1-type, returns return-type, which is converted to return-world-type. 
The sequence makes good sense to me.
And [arg1-world-type] is in a block, so I can allow more than one 
type in the future.
(if typechecking is preferred)
If routine takes no arguments, the argument block could even be optional. 
Today an empty block is needed.
sqlab
5-Dec-2011
[367]
I do not remember clear, if all versions of R2 or R3 gave warnings 
at first start, but now they are in my exception list. And at least 
once I got suspicious of R2 too, as it initialized / loaded libraries 
not needed.


The curious thing is, that now I do not get a warning at start of 
world again. And I did not allow it, but choosed "ask again".
Oldes
5-Dec-2011
[368]
I guess you will get it once you type TEST end enter.
sqlab
5-Dec-2011
[369]
right
Andreas
5-Dec-2011
[370]
Is there a way to figure out, what directory a command launches from, 
which will work across platforms?

Yes and no. There are platform-specific ways. This gist of it:

- Linux: readlink("/proc/self/exe")
- OSX: _NSGetExecutablePath
- Win32: GetModuleFileNameW

(We recently discussed this issue in relation to R3 as well.)
Geomol
5-Dec-2011
[371x4]
Topic: system/version/platform
To check for which platform, World is running on, system/version/platform 
can today be:

	"Mac OS X"
	"Linux"
	"Win32"


Is that suitable? Are there better suggestions? Is there a standard 
for this?
Maybe I should call it "Linux32" and hold the 64-bit versions clean... 
So there can be a future "Linux", which is 64-bit.
The current Linux version is compiled under Linux Mint 12 "Lisa" 
32-bit.
Andreas
5-Dec-2011
[375]
No standard, I fear. You could use the compiler's (GCC's) target 
machine verbatim, though.
Geomol
5-Dec-2011
[376]
Like:

$ gcc -dumpmachine
i686-apple-darwin10
Andreas
5-Dec-2011
[377x3]
For GCC, you can see get the target machine tuple with the "-dumpmachine" 
flag. This would give you stuff like:
i486-linux-gnu
x86_64-linux-gnu
arm-linux-gnueabi
i686-apple-darwin10
i586-mingw32msvc
Yep.
Not sure if that's the best idea, but maybe worth considering.
Geomol
5-Dec-2011
[380x2]
Yes, worth considering. But do we like to type that in scripts?
My Win32 say:

$ gcc -dumpmachine
i686-pc-mingw32
Andreas
5-Dec-2011
[382]
I think for scripts we want a small helper library with various predicate 
functions.
Geomol
5-Dec-2011
[383x2]
REBOL use this: version.revision.update.platform.variation
See: http://www.rebol.com/docs/version-numbers.html
I could add a system/version/variation at some point.
A helper lib sounds like a good idea, then I could make changes later.
Andreas
5-Dec-2011
[385]
Like: linux? windows? 32bit? 64bit? etc.
BrianH
5-Dec-2011
[386]
ARM, X86, MIPS? There's more than just OS and bits...