Commit Graph
62 Commits
Author SHA1 Message Date
Bob Nystrom bc822cd4c7 Merge branch 'master' into constructor-methods 2015-07-19 12:49:23 -07:00
Bob Nystrom d91c06d18b Tweak IO library a bit:
- Reword some docs.
- Make IO.printAll() public.
- Require () on read.
2015-07-18 14:09:00 -07:00
Bob Nystrom 5fb6186d7d Make constructors just methods.
* Eliminate "new" reserved word.
* Allow "this" before a method definition to define a constructor.
* Only create a default constructor for classes that don't define one.
2015-07-10 09:18:22 -07:00
Bob Nystrom a44e07deba Some minor doc cleanups and tweaks. 2015-07-01 08:11:10 -07:00
Bob Nystrom 70cc371379 Merge pull request #275 from sbrl/master
Document the IO class
2015-07-01 06:44:27 -07:00
Bob Nystrom 4a15653c66 Add isEmpty to Sequence.
Thanks, Michel and Thorbjørn!
2015-06-30 06:52:29 -07:00
Starbeamrainbowlabs 70d6753374 Renamed temporary filename to actual filename 2015-06-28 19:45:55 +01:00
Starbeamrainbowlabs ffddc579fd Fixed IO title and renamed file to temporary name 2015-06-28 19:45:08 +01:00
Starbeamrainbowlabs 88e209132e Updated to match standard style conventions. 2015-06-27 12:50:29 +01:00
Starbeamrainbowlabs 0dab2f4be4 Added link to IO class documentation to core index 2015-05-30 16:11:26 +01:00
Starbeamrainbowlabs d3e12980d4 Attempted to document the IO class 2015-05-30 16:10:14 +01:00
Starbeamrainbowlabs 3fd63eb2a5 Create IO.markdown 2015-05-29 10:40:16 +01:00
Bob Nystrom fcf4197139 Add Object.same(_,_) to access built-in equality even for classes that may override ==.
Had to add a new metaclass for Object since it now has its own static method so we
can't just use Class as its metaclass. (We don't want *every* class to have a same(_,_)
static method.)
2015-05-01 07:55:28 -07:00
Bob Nystrom 7c1ede0a3d Merge branch 'master' of https://github.com/munificent/wren 2015-04-22 07:45:39 -07:00
Bob Nystrom bfce24151e Tweak docs. 2015-04-22 07:45:20 -07:00
Gavin Schulz c3497ee840 Code review changes. 2015-04-19 13:32:15 -07:00
Thorbjørn Lindeijer d59031d614 Some documentation updates
Some Sequence.list references remained after it was renamed to
Sequence.toList.
2015-04-06 17:21:32 +02:00
Gavin Schulz d0bebbd380 Add docs for fiber.call. 2015-04-04 16:50:40 -07:00
Gavin Schulz 1cd83eccbc Add docs for fn.call. 2015-04-04 15:29:10 -07:00
Gavin Schulz e754fcc49f Add docs for list.insert. 2015-04-04 15:23:16 -07:00
Bob Nystrom b46828e93e Update docs for map(_) and where(_). 2015-04-01 07:31:15 -07:00
Bob Nystrom f4a836c66e Merge branch 'deferred_execution' of git://github.com/bjorn/wren into bjorn-deferred_execution
Conflicts:
	builtin/core.wren
	src/vm/wren_core.c
2015-04-01 07:22:02 -07:00
Bob Nystrom 561d46ef1d Merge pull request #241 from bjorn/sequence_each
Added Sequence.each
2015-04-01 07:10:21 -07:00
Thorbjørn Lindeijer a8ea2a91a6 Use deferred execution for Sequence.map and Sequence.where
The methods Sequence.map and Sequence.where are now implemented using
deferred execution. They return an instance of a new Sequence-derived
class that performs the operation while iterating. This has three main
advantages:

* It can be computationally cheaper when not the whole sequence is
  iterated.

* It consumes less memory since it does not store the result in a newly
  allocated list.

* They can work on infinite sequences.

Some disadvantages are:

* Iterating the returned iterator will be slightly slower due to
  the added indirection.

* You should be aware that modifications made to the original sequence
  will affect the returned sequence.

* If you need the result in a list, you now need to call Sequence.list
  on the result.
2015-03-31 22:25:07 +02:00
Thorbjørn Lindeijer c00d6ad694 Added Sequence.each
This is a bit of a style preference since of course you can always write
the same thing with a for loop. However, I think sometimes the code
looks better when using this method.

It also provides an alternative to Sequence.map for cases where you
don't need the resulting list, and one that becomes especially necessary
when Sequence.map is changed to return a new sequence. The example in
the README.md file was using Sequence.map in a way that required this
alternative in that case.
2015-03-31 21:53:29 +02:00
Bob Nystrom 07f9d4d2be Tweak Sequence.all() and Sequence.any().
When possible, they return the actual value from the predicate
instead of always just "true" and "false". This matches && and ||
which evaluate to the RHS or LHS when appropriate.
2015-03-28 10:18:45 -07:00
Bob Nystrom 53ee453f0f Merge pull request #239 from bjorn/sequence_list
Added Sequence.list
2015-03-28 09:06:49 -07:00
Bob Nystrom 5bb3154e83 Copy editing. 2015-03-27 20:59:15 -07:00
Bob Nystrom 72c38a59ce More stuff for working with strings and bytes!
- "\x" escape sequence to put byte values in strings: "\x34"
- String.byteAt(index) gets value of byte in string.
- String.bytes returns a raw sequence of bytes for a string.
- String.codePointAt(index) gets the code point at an offset as a raw number.
2015-03-27 20:44:07 -07:00
Thorbjørn Lindeijer b409569b6f Added Sequence.list
This helper method turns any sequence into a List.
2015-03-27 22:59:58 +01:00
Bob Nystrom 7d45dda383 String.fromCodePoint(). Fix #219. 2015-03-27 07:43:36 -07:00
Bob Nystrom c9226256ff Merge pull request #220 from bjorn/count_predicate
Added Sequence.count(predicate)
2015-03-23 07:35:17 -07:00
Bob Nystrom 1301410142 Merge branch 'num_methods' of git://github.com/bjorn/wren into bjorn-num_methods 2015-03-21 12:54:08 -07:00
Thorbjørn Lindeijer 07951bbeae Added Num.pi and some tests 2015-03-19 21:12:50 +01:00
Thorbjørn Lindeijer 94804fe1a0 Added Sequence.count(predicate)
Returns the number of elements in the sequence that pass the
`predicate`.

It could also have been implemented as:

  count(f) { reduce(0) {|a, b| f.call(b) ? a + 1 : a } }

But I considered the simple version more readable.

Also documented Sequence.count.
2015-03-19 21:10:05 +01:00
Bob Nystrom a3abf31da0 Merge pull request #222 from bjorn/sequence_contains
Moved List.contains to Sequence.contains, added tests and docs
2015-03-18 07:54:55 -07:00
Thorbjørn Lindeijer d7a91117ac Reverse the argument order of List.insert
The previous order, insert(element, index), was counter-intuitive.
I'm not aware of any list API that uses this order. I've checked:

* Ruby Array.insert(index, obj...)
* JavaScript array.splice(start, deleteCount[, item1[, item2[, ...]]])
* C++ / QList::insert(int i, const T & value)
* C++ / std::vector::insert
* Lua table.insert (list, [pos,] value)
* C# List<T>.Insert(int index, T item)
* Java Interface List<E>.add(int index, E element)
* Python list.insert(i, x)

So it seemed to me more like an oversight in Wren.
2015-03-15 22:51:24 +01:00
Thorbjørn Lindeijer 1099c75c77 Added Num.atan(x)
Maps to the C function atan2.
2015-03-15 16:43:02 +01:00
Thorbjørn Lindeijer 42dd7cdad4 Added more goniometry Num methods
Num.acos
Num.asin
Num.atan
2015-03-15 16:29:56 +01:00
Thorbjørn Lindeijer 09bcf5ad98 Added Num.tan
Strange omission with Num.sin and Num.cos already available.
2015-03-15 16:29:56 +01:00
Thorbjørn Lindeijer fc1dc4c54b Moved List.contains to Sequence.contains, added tests and docs 2015-03-15 15:59:42 +01:00
Bob Nystrom 5459993857 Add Class.supertype.
Thanks, Michel!
2015-03-14 09:48:45 -07:00
Bob Nystrom 05ba7d9fbf Add fiber features needed for to write an external scheduler:
- Allow yielding the main fiber. This exits the interpreter. The
  host can resume it by calling a method.
- Allow getting a reference to the current fiber.
2015-03-07 12:32:11 -08:00
Thorbjørn Lindeijer 8f985847d4 Added Sequence.any as complement to Sequence.all 2015-03-01 23:14:32 +01:00
Bob Nystrom effa69f64e Tweak docs a bit. 2015-02-27 07:37:58 -08:00
Bob Nystrom 7cb5de388d Merge branch 'doc-site-core-num' of git://github.com/hachibu/wren into hachibu-doc-site-core-num 2015-02-27 07:30:58 -08:00
hachibu ac70088e6b doc: add documentation for ceil, floor, .., and ... in num.markdown 2015-02-27 08:49:42 -05:00
Bob Nystrom 96ceaa528b Allow empty argument list methods.
- Compile them as calls and definitions.
- Use them for call(), clear(), run(), try(), and yield().
- Update the docs.
2015-02-26 23:08:36 -08:00
Bob Nystrom 4b88292ec1 Merge branch 'num-from-string' of git://github.com/gsmaverick/wren into gsmaverick-num-from-string 2015-02-25 06:53:12 -08:00
Bob Nystrom 516808f6d2 Fix typo in docs. 2015-02-25 06:49:42 -08:00