iolanguage / io Goto Github PK
View Code? Open in Web Editor NEWIo programming language. Inspired by Self, Smalltalk and LISP.
Home Page: http://iolanguage.org
License: Other
Io programming language. Inspired by Self, Smalltalk and LISP.
Home Page: http://iolanguage.org
License: Other
Is this a bug or a design decision?
test := method(
try(Exception raise) catch(Exception, return "okay")
"not okay"
)
test println ==> "not okay"
UArray seems to be doing something with \0, but I wasn't able to locate the part where it's happening.
bobry@bobry ~/coding/io % io -e ""\033[1mFoo\033[0m\n" cPrint"
33[1mFoo33[0m
bobry@bobry ~/coding/io % io -e ""\033[1mFoo\033[0m\n" print"
33[1mFoo33[0m
Source:
T := Object clone do(
doFile := method(path, "allright" println)
run := method(
doFile("zzzz")
)
)
T run
Output:
bobry@bobry ~/coding/io % io ../tmp/io/templ.io
Exception: unable to read file 'zzzz'
---------
doFile templ.io 4
T run templ.io 8
Is this the expected behaviour?
The current removeAt implementation for Sequence looks a little inconsistent to me, at least compared to the way List acts:
Io> "123" removeAt(0)
==> "23"
Io> list(1,2,3) removeAt(0)
==> 1
The following script will open the file "select * from foo", not the file "myfile.sqlite".
db := SQLite3 clone
db setPath("myfile.sqlite")
db exec("select * from foo")
db close
I'm fairly certain the offending line is here:
http://github.com/stevedekorte/io/blob/master/addons/SQLite3/source/IoSQLite3.c#L332
IoSQLite3_execWithCallback forwards its message to IoSQLite3_open if the database isn't already open. IoSQLite3_open uses the first argument of its message as the database path if there is one.
After some chat in #io, I noticed there is a handful of people that wants a minimal coding standards document.
Things like spaces/tabs, indentation, trailing spaces, naming conventions, comment styles, commit message guidelines and others should be specified at a minimum.
IoState_UserInterruptHandler shouldn't print an error message when a userInterruptHandler slot is set on System
Is there plans to document all features of language/library and to keep them in actual state?
If yes, I can maintain some piece of information.
If no, it is a pity...
asJson isn't defined for nil, false and true singletons
Io> true asJson
Exception: true does not respond to 'asJson'
---------
true asJson Command Line
Io> false asJson
Exception: false does not respond to 'asJson'
---------
false asJson Command Line
Io> nil asJson
Exception: nil does not respond to 'asJson'
---------
nil asJson Command Line
I suggest moving all the JSON related functionality from core to the JSON addon,
since it really isn't needed all the time.
According to the documentation, "Path with" should return a new Path object. However, it doesn't do this; the resulting object appears to be a Sequence, and does not listen to Path methods like absolute and isPathAbsolute.
Hello, I've noticed that List slice slot doesn't accept step argument. I'm pretty sure most of the modern language provide such a feature, for example Python:
>>> [1, 2, 3, 4][::2]
[1, 3]
It shouldn't take a lot of effort to implement this, since slice is a simple for loop.
Tag: 2010.06.06
Steps to reproduce:
Regex; "foo" findRegex("foo")
Expected: RegexMatch "foo"
Actual: RegexMatch ""
in #io, jer had this to say about it: "it might be related to a bug in Range wrt comparison during looping"
Attached is the command output for make vm.
make vm for dir in basekit coroutine garbagecollector iovm; do INSTALL_PREFIX=/usr/local make -C libs/$dir; done mkdir -p _build mkdir -p _build/objs mkdir -p _build/headers mkdir -p _build/lib mkdir -p _build/dll make _build/lib/libbasekit.a make[2]:
_build/lib/libbasekit.a' is up to date.
make _build/dll/libbasekit.dylib
make[2]: _build/dll/libbasekit.dylib' is up to date. cp source/BStream.h source/BStreamTag.h source/Base.h source/Common.h source/Common_inline.h source/ConvertUTF.h source/Date.h source/Duration.h source/DynLib.h source/List.h source/List_inline.h source/MainArgs.h source/PHash.h source/PHash_inline.h source/PortableGettimeofday.h source/PortableStdint.h source/PortableStrlcpy.h source/PortableStrptime.h source/PortableTruncate.h source/PortableUsleep.h source/RandomGen.h source/SHash.h source/SHash_inline.h source/Sorting.h source/Stack.h source/Stack_inline.h source/UArray.h source/UArray_character.h source/UArray_format.h source/UArray_math.h source/UArray_path.h source/UArray_stream.h source/UArray_string.h source/UArray_utf.h _build/headers mkdir -p _build mkdir -p _build/objs mkdir -p _build/headers mkdir -p _build/lib mkdir -p _build/dll make _build/lib/libcoroutine.a make[2]:
_build/lib/libcoroutine.a' is up to date.
make _build/dll/libcoroutine.dylib
cc -dynamiclib -flat_namespace -L../basekit/_build/dll _build/objs/*.o -o _build/dll/libcoroutine.dylib -lbasekit
Undefined symbols:
"__getmcontext", referenced from:
_Coro_setup in Coro.o
Coro_startCoro in Coro.o
_swapcontext in PortableUContext.o
"__setmcontext", referenced from:
_swapcontext in PortableUContext.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [_build/dll/libcoroutine.dylib] Error 1
make[1]: *** [all] Error 2
mkdir -p _build
mkdir -p _build/objs
mkdir -p _build/headers
mkdir -p _build/lib
mkdir -p _build/dll
make _build/lib/libgarbagecollector.a
make[2]: _build/lib/libgarbagecollector.a' is up to date. make _build/dll/libgarbagecollector.dylib make[2]:
_build/dll/libgarbagecollector.dylib' is up to date.
cp source/Collector.h source/CollectorMarker.h source/CollectorMarker_inline.h source/Collector_inline.h build/headers
make -f Makefile.local all_begin
./tools/io2c VMCode IoState_doString io/A0_List.io io/A1_OperatorTable.io io/A2_Object.io io/A3_List.io io/A4_Exception.io io/Actor.io io/AddonLoader.io io/B_Sequence.io io/Block.io io/CFunction.io io/Date.io io/Debugger.io io/Directory.io io/DynLib.io io/Error.io io/File.io io/List_schwartzian.io io/Map.io io/Message.io io/Number.io io/Sandbox.io io/Serialize.io io/System.io io/UnitTest.io io/Vector.io io/Y_Path.io io/Z_CLI.io io/Z_Importer.io > source/IoVMInit.c
mkdir -p _build
mkdir -p _build/objs
mkdir -p _build/headers
mkdir -p _build/lib
mkdir -p _build/dll
make _build/lib/libiovm.a
cc -DINSTALL_PREFIX="/usr/local" -O3 -g -Wstrict-prototypes -I. -I./source -I../basekit/_build/headers -I../coroutine/_build/headers -I../garbagecollector/_build/headers -falign-loops=16 -fPIC -DBUILDING_IOVM_DLL -c source/IoBlock.c -o _build/objs/IoBlock.o
In file included from source/IoState.h:23,
from source/IoObject_inline.h:12,
from source/IoObject.h:236,
from source/IoBlock.h:9,
from source/IoBlock.c:9:
source/IoCoroutine.h:12:18: error: Coro.h: No such file or directory
In file included from source/IoState.h:23,
from source/IoObject_inline.h:12,
from source/IoObject.h:236,
from source/IoBlock.h:9,
from source/IoBlock.c:9:
source/IoCoroutine.h:24: error: expected specifier-qualifier-list before ‘Coro’
make[2]: *** [_build/objs/IoBlock.o] Error 1
make[1]: *** [all] Error 2
make: *** [vm] Error 2
`
O := Object clone setIsActivatable(true)
assertTrue(getSlot("O") clone isActivatable)
The behavior of the Io interpreter is a bit unexpected when you have a directory named io/addons/*
in the working directory. See the following shell session.
david@third:~/test_dir$ ls -a
. ..
david@third:~/test_dir$ io
Io 20090105
Io> Random value
==> 0.3316115872003138
Io>
david@third:~/test_dir$ mkdir -p io/addons/Random
david@third:~/test_dir$ io
Io 20090105
Io> Random value
Exception: unable to read file 'io/addons/Random/depends'
---------
contents AddonLoader.io 46
Object Random Command Line 1
I believe that removing "io/addons"
from AddonLoader searchPaths
would fix the issue. Is there any reason to keep that directory in the default search path?
In most normal usage, this issue won't show up, but if, for example, you happen to have a copy of the Io source tree in a folder named io
under your current directory (which is a perfectly reasonable situation to have), it can be quite confusing.
Io> Map with("k", "v") == Map with("k", "v")
==> false
Io> Map clone == Map clone
==> false
make testvm
results in...
======================================================================
FAIL: DateTest testAsSerializationAndFromSerialization
----------------------------------------------------------------------
Exception: [d != Date clone fromSerialization(d asSerialization)] [Date_0x9b7e800 != Date_0x9b7de08]
---------
Exception raise UnitTest.io 146
DateTest assertEquals DateTest.io 51
DateTest testAsSerializationAndFromSerialization doString 1
======================================================================
FAIL: SequenceTest testAsNumber
----------------------------------------------------------------------
Exception: [Number constants nan asString != "" asNumber asString] ["-nan" != "nan"]
---------
Exception raise UnitTest.io 146
SequenceTest assertEquals SequenceTest.io 27
SequenceTest testAsNumber doString 1
======================================================================
FAIL: SequenceTest testBetweenSeq
----------------------------------------------------------------------
Exception: ["bc" != "bcd" betweenSeq("a", "d")] ["bc" != nil]
---------
Exception raise UnitTest.io 146
SequenceTest assertEquals SequenceTest.io 557
SequenceTest testBetweenSeq doString 1
======================================================================
FAIL: ObjectTest testWillFree
----------------------------------------------------------------------
Exception: [Lobby willFreeWorked != true] [false != true]
---------
Exception raise UnitTest.io 146
ObjectTest assertEquals ObjectTest.io 108
ObjectTest testWillFree doString 1
SequenceTest testBetweenSeq fails because of the following assertion:
assertEquals("bc", "bcd" betweenSeq("a", "d"))
The actual result is nil, and probably is the right result, but... what should be the expected behaviour?
http://github.com/stevedekorte/io/blob/master/libs/iovm/tests/correctness/SequenceTest.io#L556
According to Jeremy, tailCall support was removed quite a while ago, however the slot appears in the reference and is defined in the Object proto.
Io> getSlot("tailCall")
==> Object_tailCall()
I found an issue when passing the string "()", "[]" or "{}" to Compiler tokensForString. The first token returned has its line slot set to 0.
When i pass any other string, such as "Foo bar()", the first token has the line slot set to one.
The following command should return true
Compiler tokensForString("()") at(0) line == Compiler tokensForString("a") at(0) line
List asString should probably call asSimpleString
Io> list(Object clone, Object clone)
==> list( Object_0x90d3718:
, Object_0x90d3740:
)
Io> Yajl; "a\"b" asJson
==> "a"b"
asNumber should always return UTC seconds since 1970
Io> d := Date clone now
==> 2009-10-24 22:54:07 PDT
Io> d asNumber
==> 1256450047.2950639724731445
Io> d convertToUTC asNumber
==> 1256475247.2950630187988281
Regex
Io> "Hello world!" allMatchesOfRegex("\\w+")
==> list(RegexMatch: "", RegexMatch: "")
All of the tests in addons/Regex/tests/
fail, too.
Arch Linix, PCRE 8.02
On very typical Snow Leopard system, I get the following addons not compiling, due to errors: Socket, AppleExtras, ObjcBridge and SecureSocket.
Any idea why?
Hello there,
I have Gentoo box with ReiserFS partitions and Directory with("test") items
always returns a list of File
s. I made a quick debugging and found that isDirectory (IoDirectory.c) always returns 0 because dirent d_type field contains DT_UNKNOWN. Man page for readdir states that "Currently, only some file systems (among them: Btrfs, ext2, ext3, and ext4) have full support returning the file type in d_type" so I don't think that's a good implementation you have now. Changing the method to something like below would probably be a better solution.
int isDirectory(struct dirent *dp, char *path)
{
#ifdef DT_DIR
if (dp->d_type == DT_DIR)
{
return 1;
}
#endif
struct stat st;
if (!stat(path, &st))
{
return ( (st.st_mode & S_IFMT) == S_IFDIR );
}
return 0;
}
Regards,
Mike
version: d2e9b90
OS: Mac OS X 10.4.11 powerpc
error log:
../coroutine/_build/headers/power-ucontext.h:7: error: parse error before 'ulong' ../coroutine/_build/headers/power-ucontext.h:7: warning: no semicolon at end of struct or union ../coroutine/_build/headers/power-ucontext.h:8: warning: data definition has no type or storage class ../coroutine/_build/headers/power-ucontext.h:9: error: parse error before 'ctr' ../coroutine/_build/headers/power-ucontext.h:9: warning: data definition has no type or storage class ../coroutine/_build/headers/power-ucontext.h:10: error: parse error before 'xer' ../coroutine/_build/headers/power-ucontext.h:10: warning: data definition has no type or storage class ../coroutine/_build/headers/power-ucontext.h:11: error: parse error before 'sp' ../coroutine/_build/headers/power-ucontext.h:11: warning: data definition has no type or storage class ../coroutine/_build/headers/power-ucontext.h:12: error: parse error before 'toc' ../coroutine/_build/headers/power-ucontext.h:12: warning: data definition has no type or storage class ../coroutine/_build/headers/power-ucontext.h:13: error: parse error before 'r3' ../coroutine/_build/headers/power-ucontext.h:13: warning: data definition has no type or storage class ../coroutine/_build/headers/power-ucontext.h:14: error: parse error before 'gpr' ../coroutine/_build/headers/power-ucontext.h:14: warning: data definition has no type or storage class ../coroutine/_build/headers/power-ucontext.h:21: error: parse error before '}' token ../coroutine/_build/headers/power-ucontext.h:30: error: field 'mc' has incomplete type make[2]: *** [_build/objs/IoBlock.o] Error 1 make[1]: *** [all] Error 2 make: *** [vm] Error 2
Unfortunatelly the only way of getting a reference to the object being activated is:
call sender getSlot(call message name)
Which is black magic, really; even call activated
point to the Block
not, the object. Why not make call activated
point at it?
I'm not quite sure what's happening here, but Block instances handle isKindOf incorrectly. Example:
Io> Block isKindOf(Object)
==> true
Io> Lobby getSlot("forward") type
==> Block
Io> Lobby getSlot("forward") isKindOf(Object)
Exception: Object does not respond to 'self'
---------
Object self A2_Object.io 380
Block ancestors A2_Object.io 387
Block isKindOf Command Line 1
Io> SGML Exception: Error loading object '/usr/lib/io/addons/SGML/_build/dll/libIoSGML.so': 'libsgml.so: cannot open shared object file: No such file or directory' --------- open AddonLoader.io 65 Object SGML Command Line 1
But this file really exists:
$ ls -l /usr/lib/io/addons/SGML/_build/dll/libIoSGML.so -rwxr-xr-x 1 root root 88633 Мар 9 20:39 /usr/lib/io/addons/SGML/_build/dll/libIoSGML.so
create an io-only addon called MyAddon with files Tag.io and MyObject.io.
file Tag.io
Tag := Object clone
file MyObject
MyObject := Tag clone
Start Io REPL and import MyAddon.
Exception: Object does not respond to 'Tag'
Object Tag MyObject.io 1
Addon load AddonLoader.io 118
AddonLoader loadAddonNamed Z_Importer.io 51
AddonImporter import Z_Importer.io 64
List detect Z_Importer.io 64
true and Z_Importer.io 64
Object Web test.io 2
Importer import Z_Importer.io 77
CLI doFile Z_CLI.io 138
CLI run IoState_runCLI() 1
This issue arises if the word Tag appears anywhere in any object name.
Io> try(x) isNil not
==> true
Io> list(1,2,3) select(x, x > 3)
==> nil
Io> x
==> 3
Instead of creating a new context object, theese methods do setSlot() on the sender.
clang is only going to gain in prominence as a mainline compiler within many toolchains as time goes on with the aggressive stance the GPLv3 has taken on some vendors that employ GPL software. As a result, major investment has been sunk into clang development by these companies (notables include Apple), and it is to a point where it can actually be used for many applications (the FreeBSD operating system has even been ported to it).
As a result, I think it time we look at fixing Io so we can get it to build on clang. Unfortunately, all the preprocessor magic to subvert the compiler not inlining stuff we want inlined needs to be rethought. clang does not support this kind of behaviour, and fails to find many symbols because of it. We need a longer term solution.
Can somebody possibly add bindings to readline completion functions? It would be great to have customizable runtime completion in the REPL. Unfortunately, I'm not very good with C, so I can't do it myself.
I got the most recent pull from git of both Yajl and Io, and installed both. When I run Io and reference Yajl, I get this error:
justin@bug ~/s/io> io
Io 20090105
Io> Yajl
Exception: Error loading object '/usr/local/lib/io/addons/Yajl/_build/dll/libIoYajl.so': 'libyajl.so.1: cannot open shared object file: No such file or directory'
---------
open AddonLoader.io 65
Object Yajl Command Line 1
When I ls /usr/local/lib/*yajl*
, I see that everything is installed properly:
justin@bug ~/s/io> ls /usr/local/lib/*yajl*
/usr/local/lib/libyajl_s.a /usr/local/lib/libyajl.so.0.4.0
/usr/local/lib/libyajl.so@ /usr/local/lib/libyajl.so.1@
/usr/local/lib/libyajl.so.0@ /usr/local/lib/libyajl.so.1.0.8
Has anyone had similar issues, or got any suggestions for what I should do?
Io> "http://www.theoutnet.com/product/34844?cm_mmc=LinkshareUS-_-Custom-_-Link-_-Builder&siteID=J84DHJLQkR4-bR46zPTlt9punZc7OvIr5A" betweenSeq("cm_mmd=", "&")
==> /www.theoutnet.com/product/34844?cm_mmc=LinkshareUS--Custom--Link-_-Builder
Example:
OperatorTable addAssignOperator("=>", "setKey")
map := method(
call message arguments foreach(arg, writeln(arg))
)
map(foo => 2, bar => 3)
Copying to interactive produces:
setKey("foo", 2)
setKey("bar", 3)
While running as a script produces:
foo => 2
bar => 3
Shown is an interleaved Io CLI/1-second-step-ps aux output.
An Io CLI is excuted, then a mistake is make, then a 10000000
for loop. Memory is eaten nearly until 50% during loop execution.
At exit, the CLI takes ~2 seconds to complete exit.
Machine is a Debian amd64 with 4Gb RAM. Same behavior on a Debian
i686 with 2Gb RAM.
Io 20090105
Io> for(
Exception: compile error: "unmatched ()s" on line 1 character 4
message 'Error' in '[unlabeled]' on line 0
Io> for(i,0,10000000,1,s:="hello")
omf 13702 0.1 1.9 87752 77284 pts/3 R+ 22:58 0:00 io
omf 13702 0.8 11.3 469232 458748 pts/3 R+ 22:58 0:01 io
omf 13702 1.5 20.6 848336 837780 pts/3 R+ 22:58 0:02 io
omf 13702 2.2 29.9 1227836 1217280 pts/3 R+ 22:58 0:03 io
omf 13702 2.8 39.5 1617764 1607228 pts/3 R+ 22:58 0:04 io
omf 13702 3.0 42.4 1734188 1723512 pts/3 S+ 22:58 0:04 io
Io> Collector collect
Collector warning: attempt to force collection while pause count = 1
==> 0
Io>
This is since commit 5472169. The change in Project.io is looking for the build.io script inside a "build" directory.
Running unit tests on Mac OSX 10.6.2 fails as below. I haven't tried other architectures:
make testaddons
...
Obsidian - testBasic
testSimpleSync
IoCoroutine error: unable to auto abort coro 0x1005ca050 by resuming parent coro Object_0x10022a7d0
This worked as of probably 6 months ago. It's reproducible following a basic PDB workflow such as that from the examples:
User := Object clone pSlots(name)
steve := User clone steve = "steve"
PDB setPath("test.tc")
PDB open
PDB root atPut("users", PMap clone)
PDB root users atPut("steve", steve)
PDB sync
IoCoroutine error: unable to auto abort coro 0x1002c8d40 by resuming parent coro Object_0x10022b0a0
According to the docs:
Raises ... File nameConflict exception if the file nameString already exists.
The realities:
Io> f := File with("test.io") open close
==> File_0x9f73450:
Io> f exists
==> true
Io> File with(f path) exists
==> true
Io> File with("testAgain.io") open moveTo(f path)
==> File_0x9f88808:
Tag: 2010.06.06
Steps to Reproduce:
Foo := Object clone do(
newSlot("bar")
)
foos := list(
Foo clone setBar(1),
Foo clone setBar(3),
Foo clone setBar(2)
)
foos sort(bar) map(bar) foreach(print)
Expected: 123
Actual: 132
foo := method(call argAt(0) cachedResult)
foo(bar)
=> true
It seems that list map method resolves a symbol when it must not.
For example:
Io> x := list(1, 2, 3, 4, 5) ==> list(1, 2, 3, 4, 5) Io> x map(z, z ** 2) ==> list(1, 4, 9, 16, 25) Io> x ==> list(1, 2, 3, 4, 5) // all right this time Io> x map(x, x ** 2) ==> list(1, 4, 9, 16, 25) Io> x ==> 5 // and now x receives a last value of the list
Here is a part of List map method:
if(a3 == nil, a1 := a1 name self foreach(v, call sender setSlot(a1, getSlot("v")) ss := stopStatus(c := a2 doInContext(call sender, call sender)) if(ss isReturn, ss return getSlot("c")) if(ss stopLooping, break) if(ss isContinue, continue) aList append(getSlot("c")) ) return aList )
call sender setSlot(a1, getSlot("v")) -- this line seems the reason of this issue, so maybe this works as designed?
The forgotten method :)
Io> list() isNotEmpty
==> false
Io> Map clone isNotEmpty
Exception: Map does not respond to 'isNotEmpty'
---------
Map isNotEmpty Command Line 1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.