-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathwhatsnew.txt
1530 lines (1418 loc) · 74.8 KB
/
whatsnew.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
2.1-release (30 Apr 09) [update 4]
===========
- Sleep semaphores use notifyAll() instead of notify() to wake up threads.
Was experiencing deadlock on a multicore box due to the single woken
thread waiting on something else and no other threads being awoken.
- fork() now copies script environment from parent env and creates fresh
copies of all named closures. This prevents unsynchronized saved state and
closure scope variables from leaking into the forked environment.
- overloaded in operator to check if a key is in a %hash in a read only way.
i.e. "x" in %hash. Why does this matter? Read-only operations on hashes
are thread safe. %hash["unknownKey"] is a write operation when "unknownKey"
is not in the hash. This is because Sleep adds "unknownKey" to the hash
with a value of $null. In a multithreaded context this will corrupt you.
- added a sum(@a|&iter, ...) function to sum the products of all specified
arrays or iterators: (@a[0] * @b[0] * ...) + (@a[1] * @b[1] * ...) + ...
- added -isupper and -islower to check the case of a string.
- putAll(@a, @b) now puts all elements of @b onto @a.
- extended values(%hash, [@|&iter]) to accept an array or iterator of keys to
pull from the specified hash. i.e. values(%hash, @("key1", "key2", ...))
- values(...) makes copies of the scalar containers taken from the hash
2.1-release (25 Sept 08) [update 3]
===========
- fixed a problem with setField not accessing fields declared in a parent
class for an object.
- [$obj field] can now get protected members declared within the parent of
$obj. This does not extend to protected members declared up the class
hierarchy.
- added exponent operator as an assignment op i.e. $x **= 2;
- fixed a bug with cast preventing the creation of empty arrays.
- ordered hash now makes a copy of value returned by miss policy. This
prevents a situation where all members of a hash share reference to same
default value (and are thus changeable in place).
- ohash now longer serializes miss and removal policies. be warned when
you deserialize these hashes you'll want to readd the policy functions
[previous behavior resulted in a null error and corrupted the Sleep
stack, so if this affected you, you already knew and weren't happy with
with it].
- proxy instances now have a more detailed string representation. also the
string description of a proxy instance no longer calls the underlying
closure requesting toString.
- rewrote <=> to return solely 1, 0, or -1 depending on how values compare.
this replaces the old method which subtracted the left value from the right
one. avoids issues with overflowed bits this way.
2.1-release (7 Aug 08) [update 2.5]
===========
- made a sanity check with inline function execution to keep jIRCii
compatability
- fixed &sublist only front elements of read-only arrays. (another
find from the jIRCii scripting community)
2.1-release (5 Aug 08) [update 2]
===========
- modified import from to add jar file to system classpath. This
uses a reflection hack but it now means you can add multiple jars
and they can find resources from eachother, all at runtime.
This hack came from Ralph Becker's Classpath extension for Sleep.
- Sleep 2.1 default implementation no longer manages cleanup of
subroutines from unloaded scripts. The old mechanism for this
was complex and resulted in an unnecessary memory leak in
shared environments with no awareness of this feature. jIRCii
depends on this behavior and so I am moving the code for this
to the jIRCii source tree (where it manages similar cleanup
for events, aliases, and other things).
- include(...) now sets $__INCLUDE__ to the file included.
use this to allow modules to find resources that are located
relative to themselves.
- hacked <=> to compare doubles with a BigDecimal, gets around
processor floating point issues when comparing doubles
- foreach on a hash now skips over keys with $null values
(a $null value is removed at the first convienence from a
Sleep hash--usually by keys() or values() functions)
- Fixed bug causing -exists "" to return true.. turns out
toSleepFile evaluated "" to the current working directory
- Sleep functions (map, reduce, filter, etc.) that support
iterating over a closure or array and foreach loops can now
iterate over Java iterators.
- fixed a bug with taintAll causing a class cast exception with
hash scalars
- foreach now reports undeclared key/value variables when strict
mode is enabled.
- &local, &this, and &global now throw an exception if a malformed
variable name is passed to them.
2.1-release (1 Jul 08) [update 1]
===========
- splice() no longer corrupts sublists.
- values(%hash) now omits $null values.
- sped up scope functions: &local, &global, and &this by cacheing
the regex pattern used to split up the var names
- added a compile time check for %(a => ... b => ...) errors
[notice the missing comma between the key/value pairs]
2.1-release (16 Jun 08)
===========
- SleepUtils#runCode(SleepClosure, ...) now accepts a null value
for the ScriptInstance parameter.
- eliminated unnecessary frame creation within the Index operator
- added a check to cleanup the current frame when a bad index
error occurs.
2.1-beta 27 (30 May 08)
===========
- Virtual machine errors (stack overflow, out of memory) etc.
are now caught within the interpreter and used to coerce
a printout of the location of each Sleep stack frame.
- SleepClosure now implements the Runnable interface.
- fixed a null pointer exception for assertions triggered
with no preceeding statements.
- created a java.util.List compatible data structure to back
Sleep arrays. this data structure is similar to LinkedList
except it creates sublists with more desired performance
characteristics
- added better error messages for ConcurrentModificationException's
thrown by Java
- foreach loops now break if a ConcurrentModificationException
is thrown.
- reimplemented regex pattern and hasmatch state cacheing to
prevent memory leaks. Sleep will cache 128 patterns globally
and up to 16 hasmatch contexts per closure. Remember that
hasmatch will remove its state after returning false. These
measures are in place to help prevent runaway uses of
hasmatch from eating all of the memory.
- bad index errors (IndexOutOfBoundsException) are now more
descriptive in some cases.
- sublists are now serializable
- function("blah") will now throw an error if argument does not
begin with &
- empty functions now retain proper line number information
(compiler introduces a NOP into the body of an empty function)
- reworked how Sleep handles &function literals--the compiler
transforms these into a call against function('&function')--
this has the benefit of providing more debug info in a trace
and simplifying bridges that expect to receive a function as
a parameter.
- BridgeUtilities.getIterator() throws an exception if the
value on the stack is not an iterator.
- BridgeUtilities.getFunction() throws an exception if the
value on the stack is not a closure.
- Backtick expressions now use an IOObject to read in process
output.
- improved JSR223 support:
-- ENGINE_SCOPE bindings are now supported and marshalled in
as local variables
-- $__SCRIPT__ and @ARGV are now available to Sleep scripts
executed with jrunscript.
-- better handling of \r, \n, and \r\n in eval()
- sleep lexer now ignores "\r" as whitespace
2.1-beta 26 (15 May 08)
===========
- removed extra key string conversion within ordered hashes.
may offer a performance speedup in some cases.
- changed default capacity of ordered hashes to 11 (previous
value was 16 which is bad for random distribution of values)
- TaintUtils.taintAll now handles KeyValuePair objects
- added TaintUtils.taint(Stack) as another shortcut for bridge
writers / integrators.
- BACKWARDS COMPAT WARNING: updated &indexOf and &lindexOf to
return $null when no match is found. This is a change from
their original return value of -1. $null is == to 0. However
this does enable a cleaner means for iterating with indexOf.
$index = -1;
while $index (indexOf($string, "token", $index + 1))
{
# ...
}
# do something with substr($string, $start + 1)
- added &find("string", "regex", n) which returns the index of
the substring matching the specified regex beginning at n.
&matched() works to retrieve the matched groups from the
substring.
- conducted a 3am cleanup of the RegexBridge--you know what
that means.
- updated array implementation to use a LinkedList in lieu of
a Stack. This offers better performance characteristics for
most array operations. The only real losing operation is
random access which now has a worst case of O(n)
- inline functions now restore anonymous arguments and @_ prior
to returning control to the parent function.
- renamed &subarray to &sublist(@array, n, m). Updates to the
returned &sublist will affect the parent list.
- updated &splice to use new ScalarArray sublist API... this
new implementation scales better
- &clear now clears each element from the array rather than
creating a new array and returning it.
- added &concat(@a, @b, ...) to concatenate multiple arrays
- split('pattern', 'text', [limit]) now accepts a limit
parameter to allow partial splits of text.
- added function inline({ .. }) to invoke the specified block
inline
- added JSR223/javax.script API support. sleep.jar is now a
service provider for this API. See jsr223/readme-jsr223.txt
for more information.
- Reworked the ScriptLoader compiled code cache. It works mostly
as before except now an unloaded script will not delete the
entire cache. This was put in place to account for &include'd
scripts. Now &include validates its last modified timestamp
with the ScriptLoader prior to (re)loading.
- fixed bug in SleepUtils.getArgumentStack(Map)
- added a hasChanged() method to ScriptInstance to help apps
determine if a script (or any script it has included) has
changed.
2.1-beta 25 (8 May 08) [will this beta process ever end?]
===========
- added &chdir() to change the current working directory of the
active script instance. This value is inherited by fork().
All I/O and File System bridge functions that manipulate files
(including exec) utilize the current working directory. Use
&cwd() to obtain the current working directory value.
- &readb($handle, -1) will attempt to read all bytes from the
specified handle.
- I/O functions are now smarter about checking their arguments.
- replaced test.pl regression tester with a Sleep version.
The Sleep version is much faster and it is forgiving of
address and installation path differences.
- implemented taint wrappers for the Map->Hash and Collection to
Array wrappers obtain with SleepUtils. The TaintUtils.taintAll
method is intelligent enough to employ these against wrapped
data structures when necessary.
- changed implementation of foreach to more efficiently iterate
over hashes. remove() w/i a foreach loop now works with hashes.
- removed sleeplang.html from the repository and added a .url
file pointing to the Sleep Manual. When the manual is complete
I will create a .pdf and distribute it with the Sleep source.
- &warn no longer shows as a function call in debug traces
- fixed line number skew with the else if and else blocks of
if statements.
2.1-beta 24 (30 Apr 08)
===========
- refactored Parser/CodeGenerator to use a factory pattern for
generating atomic steps.
- changed implementation of PLiteral to precalculate all values
onto the current frame... the atomic step itself joins the
frame values together. No change from scripter perspective.
- removed the %BACKQUOTE% and Evaluation bridge. The backquote
behavior can still be overriden using a Function object
keyed to __EXEC__.
- added taint mode similar to Perl. taint mode allows bridges
to flag scalars as having come from an external source. All
scalars touching said scalar are considered tainted until
&detaint is called on the tainted scalar. Certain functions
will check for the presence of tainted variables and refuse
to process if a tainted value is present. Examples include:
exec, `...`, eval, expr, compile_closure, and any HOES call.
Bridges may optionally check for this taint mode on their
inputs. i.e. Slumber is a good candidate for this.
This mechanism can help you build a more secure app by
forcing you to sanitize external values before using them
in dangerous contexts.
This property is enabled with -Dsleep.debug=true on the
command line.
Bridge writers--see sleep.taint.TaintUtils for information on
how to add taint checking to your app. The mechanism is
very easy and just involves calling a function on your
Function, Operator object that will wrap it based on where
it falls.
Scripters use &taint($scalar) to explicitly taint a value and
&untaint($scalar) to untaint a value. And -istainted to
check if a scalar is tainted or not.
- added debug level 128 for tracing the spread of tainted values
- SleepUtils.describe does better cycle detection allowing Sleep
to better print circular data structures. %n and @n refer to
the n'th data structure starting from the outermost working
in to the inner most.
2.1-beta 23 (23 Apr 08)
===========
- removed a Java 1.5 API call in CodeGenerator (thanks to
Ralph Becker for catching this one).
- API CHANGE: Loadable interface methods now have a return
type of void instead of boolean. This is an API wart I
couldn't live with any longer.
- added command line option -p/--profile to collect and print
profiler statistics for the specified script.
- added command line option -t/--time to print out the total
running time of the specified script
- ordered hash miss policy now receives the passed in key
as-is prior to the string conversion.
- Sleep now parses command line arguments in a more flexible
manner allowing different orders/combinations of switches.
- sleep.classpath value accepts either a ; or : as the path
separator.
- moved the %RANDOM% object to the ScriptInstance metadata
with key __RANDOM__ (used to store random number seed)
- SleepUtils.describe(...) makes some attempt to detect
cycles (i.e. data structures that reference themselves)
when printing out the data. An ellipse is used to indicate
the data structure references itself.
2.1-beta 22 (17 Apr 08)
===========
- added a new API to SleepUtils to generate a variable stack
from a java.util.Map.
- I/O bridge now reports a better error when a I/O handle is
expected as an argument but not received.
- added -Dsleep.assert property to enable/disable assertion
statements.
- updated SleepClosure#callClosure to use the current preferred
function calling methods. This enables closure calls from
map, reduce, search, etc. to be traced and to count against
the profiler statistics
- SleepUtils.runCode(Block, ...) now creates (and assumes the
responsibility for destroying) a local scope if none currently
exists.
- extended the ordered hash (&ohash) concept to allow the
implementation of a cache with a Sleep hash interface:
-- &ohash orders keys in insertion order (no surprise here)
-- added &ohasha to create a hash with keys kept in access order
-- added setRemovalPolicy(%hash, &closure) to set a closure that
determines wether the last element of the specified hash
should be removed or not. Arguments to the closure are:
$1 = the hash, $2 = the key, and $3 = the value.
-- added setMissPolicy(%hash, &closure) to a set closure that
determines what value to use when a hash access misses.
The closure is called with $1 = the hash and $2 = the key
These features should enable better management of massive data
structures within Sleep. Someone *cough*Marty*cough* will
benefit greatly from this.
- sleep.runtime.ScalarHash implementations are now responsible
for creating their own toString representation. This is
necessary as some hash implementations (i.e. &ohasha) are
sensitive to access order. Added a helper function to assist
with creating a String representation from a java.util.Set of
java.util.Map$Entry. SleepUtils.describeEntries(String, Set)
- profiler now reflects time spent in current function sans
child function calls. avoids numbers getting out of whack
due to recursion.
- created a new means for storing script metadata information.
the java.util.Map obtained by ScriptInstance.getMetadata()
is stored in the global variables for a script and it is
passed on to child forks. The script "environment" where
functions and such are stored should not be used for
keeping state.
This breaks backwards compatability if you install a new
Sleep console as %console% or if you manipulate script
statistics directly by accessing %statistics%
To set the Sleep console use the static method in
sleep.bridges.io.IOObject#setConsole(ScriptEnvironment, IOObject)
2.1-beta 21 (28 Mar 08)
===========
- assignment loops now record proper line number information for
error reporting purposes.
- added a ? command to evaluate predicates in the Sleep console.
- index operator can now be applied to backtick expressions
- collapsed implementation of &skip and &consume; they now refer
to the same function.
- added &readAsObject and &writeAsObject to read/write serialized
Java objects (in lieu of sleep.runtime.Scalar objects)
- updated © to also copy scalars and hashes.
- added &pushl and &popl for creating and removing local scope,
arguments to these functions are used to pass data between the
current and resulting local scope.
- fork now passes copies of its arguments into the forked scope.
this is in line with how lambda, let, etc.. work. pass a data
structure (such as an array or hash) to have updateable shared
values.
- round function can now round to a desired number of places.
- replace function can now handle empty arguments, it will use
empty strings in their place.
- added &warn to send a message to the script warning watcher
installed within the script environment...
- true and false arguments are now optional in iff expressions:
iff(3 == 3) = 1
iff(3 != 3) = $null
- &push can now push multiple arguments
- added &scalar($object) to force object through the Sleep scalar
conversion process.
- continuations now save multiple levels of local scope if
necessary (this makes pushl/popl safe for yield/callcc)
- inline functions will only mangle @_ if unnamed values are
passed. Use $var => ... to pass a named value.
- toplevel sleep scripts are now executed as a closure... this
allows callcc to work from the top level.
- fixed a memory leak caused by stack pollution within loops.
- callcc can now be used within fork to take control of the fork
and eventually return a value (retrievable via &wait)
- fixed a callcc corner case that could lead to an infinite loop
in the interpreter
- refactored the SleepUtils.runCode(...) methods to use the
standard Sleep mechanism for evaluating functions.
2.1-beta 20 (12 Nov 07)
===========
- fix debug mode 24 error handling inconsistency bug.
- $null passed as a Java string now evaluates to null and not ""
- sleep arrays now allow $null elements when converting to Java
arrays.
- updated fork() to use script name AND line number information
for thread description. will aid debugging.
- updated read-only array, hash wrappers to display a warning
when a script attempts a modifying operation
- updated array, hash wrappers to marshall wrapped types into
Sleep types as appropriate.
2.1-beta 19 (24 Oct 07)
===========
- sleep interpreter now performs better stack hygeine to prevent
exceptions and errors from corrupting the stack inadvertently.
- $null now deserializes as its singleton value. this fixes a lot of
potential pitfalls for scripts that rely heavily on serializing and
deserializing Sleep functions.
- closure context metadata (regex matcher and iterator for foreach
loops) is no longer serialized with the closure... beware of this.
- added &ohash(...) to initialize a Sleep hash that keeps track of
key insertion order. requested by Marty.
- updated the sleep listen(...) and connect(...) functions to accept a
number of key/value options. options include:
linger => the value of SO_LINGER (how long (ms) the socket waits
for a TCP reset before actually closing.
lport => the local port to bind to
laddr => the local address to bind to
backlog => the number of connections to queue while waiting for
a subsequent call of listen(...) to accept a
connection.
for example, to listen on port 8888 of 192.168.1.1 while allowing
only 1 connection:
$handle = listen(8888, laddr => "192.168.1.1", backlog => 1)
listen will only honor the extra parameters the first time the
port is intialized. the extra params will have no effect on
subsequent calls to listen. to fix this call closef(port) to
unbind the specified port.
- added inline functions. these are more like poor mans macros than
anything else. an inline function is executed inline with the
current function, it shares all scope information and any attempt
to return/yield/callcc values will affect the parent directly.
inline return12 { return 12; }
inline functions themselves always give back $null in an expression.
using an inline function within an expression is not recommended.
callcc/yield behavior within an expression will break things.
- major refactor of Sleep's logic flow for managing function calls, debug
options, etc.. to one file. please report any bugs
- added callcc to Sleep. callcc packages up the current function (as
with yield) and then it calls the specified function with the packaged
current function as an argument. combine this with the new inline
functions feature and there is all kinds of fun to be had.
2.1-beta 18 (5 Jul 07)
===========
- added scalar references: \$x is equivalent to $x => $x. this sugar
was added for the common case of passing a key/value pair to copy a
scalar into the local/this environment of a function.
- added a srand(long) function for seeding the Sleep random number
generator. %RANDOM% in the script environment contains the random
number generator reference.
- Sleep now evaluates text within a back ticks as an expression to
execute. The expression returns an array with the output printed by
the executed command. Execution errors and non-zero process termination
value are available via checkError()
- Scalar hashes can now be passed to Java methods expecting an Object
value (if desired)
- character arrays returned by Java calls will now be converted to a
Sleep string
- Sleep strings will now be recognized as valid matches for Java methods
requesting a byte[] or char[] parameter.
- Sleep scalars returned by Java calls will be returned as is.
- improved performance (x3) of Sleeps internal functions to convert a
String to a non-mangled byte array.
- &remove now returns data structure data was removed from
- extended &add to accept a hash and multiple key/value pairs for
adding stuff to an existing hash.
- Sleep's set operations removeAll, retainAll, and addAll now work based
on scalar identity in lieu of string representation
- Added "in" operator to check if a scalar with same identity is contained
within an iteratable data structure (generator function / array)
- Added =~ for comparing two scalars by identity (scalar that reference
something are identical if their references match, other scalars are
identical if their string reps match).
- fixed a bug causing import to crash parser when no package was specified
- Sleep parser now checks if a class exists when it is imported
2.1-beta 17 (17 Jun 07)
===========
- reduced number of Class.forName calls made when parsing scripts...
should help those using Sleep in Java applets ;)
[p.s. sorry I wasn't able to take care of this sooner]
- added a new type of literal for resolving a Java class i.e.:
^java.util.LinkedList resolves to java.util.LinkedList.class
^Map$Entry would resolve to java.util.Map$Entry.class etc..
- added a new predicate 'isa' for determining if an object is a
instance of a specific class i.e.: "string" isa ^String
- added a better error message for class cast exceptions caught w/i
the interpreter.
- added a $__SCRIPT__ variable to indicate the name of the executed
script when running a Sleep script from the command line.
- added a typeOf($scalar) function to retrieve the class backing the
specified scalars value.
- added the ability to specify a failure message with an assert i.e.:
assert <predicate> : <message>;
- setField can now accept a class literal as its first argument for
updating a static field
- &use can now accept a class literal as its first argument (safer
than specifying bridge as a string as class literals are resolved
at compile time)
- updated &cast and &casti to allow a class literal to be specified
as the type to cast to.
- added a lindexOf function to obtain the last index of a substring
- sleep console now shares one pool of imported packages for evaluations
- added newInstance(^Class|@, &closure) for creating a proxy instance
of a Java object backed by the specified interfaces
- try/catch is no longer dependent on putting the caught value into
the global scope.
- returning within a try block no longer breaks Sleep's exception
mechanism.
- &exit can now be used within a try/catch block
2.1-beta 16 (11 Jun 07)
===========
- passing a value that can not be used as a key/value pair when a kvp
is expected now results in an error message. valid kvp's include:
expressions of (key => value) and strings with the form "key=value"
- added getIOHandle(InputStream, OutputStream) to SleepUtilities class
- registered cmp operator to prevent parser confusing it with a function
- hashes/arrays can now be passed as named parameters to closures
- &size now works with hashes
- the '.' command in the console interact mode will now repeat the last
code sequence if no new code has been specified.
- fixed a bug with &let, &lambda: when a ($this => ...) is specified
all subsequent variable placements will be put into the shared this
scope.
- &compile_closure now shares its implementation with &let, &lambda
allowing it to function as they do for settings vars, passing $this
scope, etc..
- &join, &flatten functions now accept either a sleep array or generator
function.
- &readObject no longer throws an EOFException.
- added another debug mode: DEBUG_TRACE_LOGIC (64); use this to trace
the results of all predicate evaluations
- cleaned up the code in BasicNumbers a bit to reduce the file size
- cleaned up the implementation of &remove(%|@, ...), the function now
removes based on values (and not keys); comparisons are made as follows
hashes, arrays, and object scalars are compared by reference, everything
else is checked by string value.
- fixed improper uses of (<Scalar>n).getValue() throughout the Sleep codebase.
this function builds discardable string representations of hashes/arrays.
sometimes this behavior is desired, usually its not. these changes will
increase performance when using arrays/hashes extensively.
- &removeAt can now remove elements from arrays or hashes, multiple keys
can be specified as well. the function no longer returns a value.
2.1-beta 15 (25 Apr 07)
===========
- fixed a potential problem that could arise when one attempts to
query which file is currently executing and no file is executing.
- made the ProxyInterface class in sleep.engine public. For those of you
looking to embed Sleep, a Sleep closure backed instance of a Java
interface may be the way to go. Using the ProxyInterface class you
can create these closure backed instances and you get all of the built-in
function call tracing, profiling, error checking, etc. for free.
- the outer most frame of execution for running a Sleep script now enjoys
the same thread safety/synrchronization that the rest of the Sleep
functionality adheres to.
- exit() function now allows an optional string parameter which will be
reported to the user as a runtime warning (usually an indicator of why
the script chose to exit?)
- added an assert command. assert takes a predicate expression as a
parameter. if the predicate expression does not evaluate to true then
the currently running script will exit with the message "assertion
failed".
- HOES expressions with no arguments following the : will report a
syntax error (originally this error was crashing the parser)
- Proxy instantiations of Java classes are now synchronized in the same
way as the rest of Sleep's interpreter and source information is now
installed to show calls on these classes as coming from <Java>
- fixed a bug that disallowed importing multiple packages from a single
external jar file.
- unloading a script through ScriptLoader now causes the entire block
cache to be cleared. This will ensure that external files loaded
with include() will be purged from the cache as well.
- fixed a bug with iswm and using \ as a character literal in the match
pattern, use \\ to specifiy a literal \
- altered HOES argument resolution for Sleep hashes and arrays; no longer
will either of these types match to a method requiring a generic Object
as an argument. Collection/List/Object[]/ScalarArray for Sleep arrays
and Map/ScalarHash for Sleep hashes.
- updated cast/casti with a new pattern character, 'o' which will create
a java.lang.Object based on the specified scalar.
- reworked conversion of array scalars to native Java arrays and enhanced
error messages. In general Sleep will try its best to convert all of
the array elements to the same type (type determined by first elements).
Use cast(@array, "t") to cast the array to the type you really desire.
2.1-beta 14 (24 Mar 07)
===========
- added splice(@array, @insertme, position, n) for modifying an array.
works a lot like replaceAt, i.e. up to n elements at the specified
position are removed and the elements of @insertme are put in their
place. @array is modified in place.
- array functions now normalize negative parameters as offsets from the
total length of the array. updated functions include:
&add, &removeAt, &search, and &subarray.
- added a check to ensure regex pattern cache is flushed every so often.
- tracing/profiling now records Java calls on closures passed as psuedo
objects.
- the import/from syntax now allows the jar filename to be quoted with
double or single quotes to specify a path with spaces.
- fixed a bug with normalized parameters (for both arrays and strings)
2.1-beta 13 (18 Mar 07)
===========
- trace debug option now reports the parameters for a HOES call even if an
exception is thrown.
- psuedo objects now make an attempt to convert the returned scalar to the
java type expected by the method. (oops, oversight on my part :))
- Sleep's flag error function now accepts and returns an Object value. This
has big implications as checkError($error) can now return the original
error causing Object (i.e. a descendent of Throwable) that can be
manipulated with HOES. But oh wait... there is more...
- added a try/catch blocks to Sleep. try/catch blocks are used to catch
exceptions thrown by sleep scripts and the sleep interpreter. the
syntax is:
try { ... } catch $varname { ... }
try try/catch system works as you would expect, if an exception is thrown
Sleep will jump to the top level try and execute the corresponding catch
block filling in $varname with the exception that was thrown.
- added a getStackTrace() method that returns an array of the sleep stack
trace caused by the latest exception.
- added a throw keyword that works quite similiarly to return except it
throws a message (or exception). Any arbitrary scalar can be used with
throw.
- added a new debug option (DEBUG_THROW_WARNINGS) to force anything flagged
for retrieval via checkError(...) to be thrown as an exception within Sleep.
The number is 34. This is put in place to prevent breaking backwards
compatability with older scripts that rely on the checkError() scheme.
With this option scripters can choose to use try/catch blocks for all run
of the mill error handling. (see how it all fits together now?)
- added an &exit() function to force Sleep to stop processing within the
current script environment.
- updated sleep library to force functions to pass exceptions for consumption
by checkError() in lieu of strings. This means the error messages are
somewhat less descriptive but on the other hand you can fully inspect them
for whatever additional details you want.
- fixed a bug preventing use of increment/decrement ops in expression context
- fixed a bug causing @_ to return the same size value no matter how many
modifications had been made to the array (thanks to Ralph Becker for
finding this one).
- made a small (possibly negligible) performance optimization to Sleep's
scalar value transfer code.
- fixed frame leaks that can occur when a Java exception interrupts the
calling of a function.
- added yet another option to help with debugging: watch('$x $y $z')
this function will ensure a warning is fired every time the scalar
container held by the specified variables receives a new value.
2.1-beta 12 (11 Mar 07)
===========
- fixed yet another flurry of line number skew issues. argh, make it stop!
- renamed &unlambda to &let, this name makes much more sense
- added APIs to the script loader class to compile a script without the
overhead related to loading the script. This is useful when a script is
going to be run in the environment of another script.
- improved tracking of source file information for blocks of code. error
messages and closure string representations will now accurately represent
the code's origin information.
- added an &include function for including code from other sleep scripts.
included code is included as if it is part of the current source file.
include(["/path-to/jar-file.jar"], "directory/filename.sl");
- SValue atomic step now returns a copy of the scalar literal and not a
reference to the scalar. This prevents constants from being "changed"
on accident.
- Added a -e|--eval and -x|--expr command line options to sleep.jar; these
options allow whole scripts/expressions to be specified on the command
line for evaluation.
- Updated &indexOf to accept an optional start parameter.
- Updated numerous string functions to allow negative indice parameters.
&left, &right, &mid, &replaceAt, &strrep, &charAt, &substr, &indexOf
- added a check to &readb to see if the handle is closed prior to attempting
a read. If the handle is closed $null is returned.
- fixed bugs in &readb that come about when reading in the last chunk of
data that is usually smaller than the total buffer size.
- added a new I/O handle type: the buffer. this can be used to construct
and manipulate very large strings of data in memory. use &allocate()
to allocate a writeable buffer. the first time &closef is called the
buffer will flip to a readable buffer. the second time all the resources
will be cleared.
- pack/unpack/bwrite/bread can now parse sleep scalars with the 'o' format
- added another form of &exec that allows the command/arguments to be
specified as an array. useful for including arguments with spaces in
them.
- rewrote parsed literal parser and atomic step to fix several bugs
... strings ending with a $ will no longer see the $ stripped off
... \\\" is now \" as expected
- added a &byteAt function which works like &charAt except it returns an int
2.1-beta 11 (3 Dec 06)
===========
- multi-line parsed literals now make a more sincere effort to track which
line number a variable was encountered at.
- fixed a bug with multi-line parsed literals where a variable followed
immediately by a tab or newline was not being "terminated"
- fixed a bug with && and & followed by a HOES expression being mistaken
for a function reference token.
- added &unlambda function that works exactly like &lambda except it does
not create a new closure (rather it manipulates the this scope of the
passed in closure and returns the passed in closure).
- added a profiler to sleep... I know, you should be scared. Use the
DEBUG_TRACE_CALLS (8) or DEBUG_TRACE_PROFILE_ONLY (24) debug options to
enable it. Profiler statistics are available in the ScriptInstance class
with the getProfilerStatistics method. Scripts can access their profiler
statistics with the &profile() function which returns an array.
- fixed a line number skew issue with multi-line tokens passed as parameters
to a function/expression.
- fixed a line number skew issue when approximating the line numbers where
a closure originated.
- added a -a/--ast command line option to dump the abstract syntax tree
for the specified script.
- fixed a coroutine bug where consecutive yields happening within a nested
block were not properly saving the nested context.
2.1-beta 10 (20 Nov 06)
===========
- added sizeof("data format") to return the size (in bytes) of the
data structure represented by the specified format string.
- attempting an invalid usage of the index op now fires a runtime
warning notifying the scripter of what happened.
- added \x and \u escapes for parsed literal strings... \x## allows a
char to be specified and \u#### allows a unicode char to be specified.
# is expected to be a valid hex character.
- updated println, readln, read, readAll, and printAll to be unicode
aware, the platform encoding is used by default.
- added &setEncoding($handle, "charset name") to set the encoding to use
with the specified handle.
- added &readc($handle) for reading a single character from an I/O handle.
- parser no longer assumes a bareword in a expression is a function handle
reference. should stop some frustrating errors :)
- fixed a silly bug with tuple assignment where hash right hand side was
being converted to a string before being assigned to the individual
elements.
- added assignment ops i.e. +=, -=, *=, /=, &=, |=, ^=, <<=, >>=, and .=
using these ops will assign the result of the op applied to the assignment
value and the right hand side. this works as expected with normal
and tuple assignment.
- using a tuple assignment op has a special case: expand array
a single array value specified within a tuple will be expanded as if each
of its elements were specified within the expression i.e.:
(@a) += @(3, 4, 5); is equivalent to: (@a[0], @a[1], @[2]) += @(3, 4, 5)
- fixed &consume($handle, n, [size]) to now consume up to n bytes with a
buffer of the specified size. this will consume a handle without
keeping the whole thing in memory (useful for calculating md5 digests
of files and other fun things).
2.1-beta 9 (6 Nov 06)
===========
- made sleep data structures and sleepclosure all serializable.
- added &readObject([$handle]) and &writeObject([$handle], $object) to
read/write scalars to a handle. if you think about what is possible
with closures/coroutines and friends then you are thinking right. this
should scare you.
- fixed a nasty nasty (x 1000) performance issue with hashes and arrays of
any significant size. A null check in the Index operator was inadvertently
converting the entire data structure to a string each time an index op
occured. thanks to Marty for making me aware of this one.
- added &consume($handle, n bytes) to read and discard up to n bytes from the
specified handle. (differs from skip which just seeks ahead and discards
n bytes).
- IO errors in read/write functions now uniformly close the read/write
portions of the IO handle.
- remove &getFilePath as the function essentially did nothing but return
the value passed to it (I was a little over-ambitious when bridging
java.io.File awhile back).
- ls() with no parameters now returns the listing of files/dirs in the
current directory.
- fixed a bug with 'x' crashing the sleep console when the expression
had a syntax error.
- added a -c/--check option to the sleep interpreter to specify the script
should be parsed and checked for syntax errors but not run.
- &add now behaves as documented, if no index is specified then the value
is added to the beginning of the array (and not the end as in push).
- HOES method resolution now matches 1 character sleep strings as Java
characters.
- the index operator now normalizes negative array indices i.e. @array[-1]
will return the last element of @array.
- added more descriptive error messages for out of bounds exceptions and
null pointer exceptions.
- fork() now inherits parent scripts debug settings and error watchers,
before if an error happened in a fork it would be silently ignored. doh!
- &use is now much more aggressive with its error reporting. if the class
is not found or if the specified jar file is not found a runtime warning
is fired.
2.1-beta 8 (29 Oct 06)
===========
- when packing an unsigned integer the argument is now interpreted as a long
(and cast to an int) rather than an int (since an unsigned integer can be
"bigger" than a normal java integer).
- fixed a parser ambiguity with hash literals i.e. %(...) and arithmetic
consisting of ... % (...). both now work as they should.
- fixed assignment loops creating an extra non-needed stack frame
- added a sanity check to the assignment step, checks for a "corrupted"
assignment stack, most commonly caused by forgetting to terminate the
assigned expression with a semicolon.
- added BridgeUtilities.extractNamedParameters(Stack args) to extract all
named parameters from a stack of arguments.
- changed string representation of closures to represent:
&closureX:N-M where X represents the instantiation number (i.e. closure 3)
and N-M represents the line range where the closure was declared
- updated &invoke to accept the following named parameters:
parameter => %() - accepts a hashmap of $scalars to send as named parameters
$this => &closure - accepts a closure to use as $this when executing the
function. essentially forces the called function to share environments
with &closure for the duration of the execution.
message => "some string" - the message value to send to the called function
- updated the sleep console with an ehanced 'help' command and a command 'debug'
to set the debug level of a script.
- one can now specify a $this => &closure with &lambda to force the new closure
to use the closure scope/environment of the specified &closure
- added a &putAll(%hash, &/@, [&/@]) to populate the passed in hash from the
passed in iterator(s).
- updated &exec to allow specification of a starting directory and environment:
$handle = &exec("command args", [%environment], ["starting directory/"]);
- readb now returns a $null if the read failed to return any data
2.1-beta 7 (15 Oct 06)
===========
- index operator can now be applied to closures to reference the "this" scope
of the closure i.e.
$closure = lambda({ println("I am: " . $name); }, $name => "Burt");
$closure['$name'] = "Joe";
[$closure];
Output: "I am Joe"
- added -isfunction predicate to check if a scalar contains a function or not
- added &invoke(&function, @args, [message]) to invoke a function with @args
passed as individual arguments.
- updated &setField to accept key/value pair arguments where the key specifies
the field to update and the argument the value, any number of args can be
specified. this breaks to behavor set in 2.1-b6
- added a -h/--help command line option (:
- specifying a - on the sleep command line reads the script from STDIN
2.1-beta 6 (1 Oct 06)
===========
- added named parameters for Sleep closures. When a $key => value argument is
passed to a sleep closure the value will be installed into the local scope of
the function as variable $key. This breaks the old behavior which was to
convert the key/value pair into a string i.e. $key=value
- improved function call traceing to detect when a function call failed and to
indicate that such an event occured.
- coroutines are now allowed to call themselves in a recursive manner
- when yield is called, the local variable state is preserved until the
coroutine is called again (only when the coroutine is reset, i.e. exited w/o
a yield is the local variable state dropped).
- added an error check for attempts to pack odd length hex strings
- parser now throws an error if a jar file specified with import * from: is not
found.
- added a &setField(class|$object, "field", value) function for setting the
value of a field in a Java class or object.
- added &setf('&function', { closure }) for setting a named closure (i.e. a
subroutine).
- closure this scope is now associated directly with the closure itself and not
just its script environment. the implication of this is passing a closure
to a fork will carry the closure this scope with it as well (and also the
local scope in the case of a partially executed coroutine).
- added semaphore synchronization primitive to the sleep language:
# initialize a semaphore
$semaphore = semaphore([initial count]);
# acquire the semaphore
acquire($semaphore);
# release the semaphore
release($semaphore);
2.1-beta 5 (17 Sept 06)
===========
- fixed a bug with import [path] from: [jar] not working when a package.class
combination was specified.
- fixed a bug where HOES was not recognizing sleep arrays as a valid argument
for methods/constructs expecting multidimensional arrays.
- HOES mapping scalars to Java arguments is now a little bit stricter and more
accurate.
- added &casti(value, "t") to cast the specified value into a Java primitive type.
- altered the semtantics for how Java Object values are converted to Sleep
scalar number values. Essentially the Object is converted to a string and the
string is parsed with the following meaning:
<not a number> = 0
"true" = 1
"false" = 0
"" = 0
<a number> = <a number>
The old semantics (object hashcode) were worthless so I doubt there will be
many complaints.
- added checksumming capability to sleep, the function has the following forms:
$summer = checksum($handle, "[[>]CRC32"|"[>]Adler32");
$sumvalue = checksum($summer); # when I/O on $handle is complete
or:
$sumvalue = checksum("string of data", ["CRC32"|"Adler32"])
The CRC32 and Adler32 algorithms are supported. With an I/O handle specifying
a > before the algorithm name indicates that written data should be checksummed.
- added digest capability to sleep, the function is similar to checksum except
the function name is &digest. The MD5 and SHA-1 algorithms are supported.
This function returns a string of bytes (can be converted to hex using
unpack("H*", $digest_data)[0]).
- added H/h to the binary format templates to allow byte data to be converted
to/from hex characters. The H puts the high nybble first and the h puts the
low nybble first.
- fixed a bug with &pack destroying the binary string thanks to Java's lack
of unsigned types.
- When a Java byte array is returned by a HOES call, a sleep byte string will
be created from this value.
- fixed a deadlock issue with fork/wait with close being called on fork while
in the middle of a read.
- sleep I/O now uses the IOObject stored in the environment under %console% as
the source for stdin/stdout (this is set to System.in and System.out by
default).
2.1-beta 4 (11 Sept 06)
===========
- added a literal form for arrays and hashes:
@("a", "b", "c", "d", "e", @("f", "g", "h", "i"), "j", "k")
%(a => "apple", b => "batman", c => "cow")
- fixed a bug in the Sleep parser transforming long/int literals
into ObjectValues rather than LongValue/IntValue.
- string form of arrays and hashes (when converted to a string) is now
consistent with the sleep literal form
- added another debug level (8) for function call tracing. while this
flag is set all function calls with their arguments and return value
will be displayed to the user as a runtime warning. Enable with:
debug(debug() & 8);
- HOES will now allow sleep data structures (arrays and hashes) to be passed
as java.util.List and java.util.Map data structures (via an expensive
conversion process). This conversion only applies one way i.e. a Java List
or Java Map can not be used as a Sleep array or hash.
- added the ability to import classes from external jar files into sleep:
import org.jdom.* from: jdom.jar;
Sleep also has a concept of a Sleep classpath, definable with sleep.classpath
or through the static methods in sleep.parser.ParserConfig.
- updated the use() function to use the sleep classpath to search for the
specified jar file.
- fixed lambda({}, $x => $y) sharing scalar container references (caused a
change to $x inside of the closure to affect the value of $y)
2.1-beta 3 (18 Aug 06)
===========
- added an optional timeout parameter for the socket connect function i.e.:
$socket = connect("host", port, [timeout in milliseconds])
default is 60 seconds.
- modified listen to create a server socket and bind to the specified port,
each call to listen is a call to accept a connection on the specified port.
to stop listening on the specified port use closef(port number) instead of
$handle.
- added a function global to declare a series of variables into the global
scope
- added a require strict debug flag, this flag causes a runtime warning to
be fired whenever a script uses a variable without delcaring it using
global, local, or this.
- added &debug(mode) allows scripters to programatically set the debug flags
for their script.. debug with no arguments returns the current debug flags
levels are:
1 - show errors: dump all critical script errors as runtime warnings, this
should never be turned off.
2 - show warnings: dump all non-critical script exceptions as runtime
warnings. These can be checked for programatically with &checkError
4 - require strict: dump all first time uses of non-declared variables as
runtime warnings.
any of these flags can be OR'd together i.e.:
debug(1 | 4); # show all errors and uses of non-declared variables
- when passed an array parameter, &rand will return a random element of the
array.
- eliminated the use of a busy loop to wait for a timeout within the &wait
function
- &wait when called on a process will now wait for that process to exit
and return the exit value of the process.
- added a new function to BridgeUtilities to extract an "iterator" from the
argument stack, this iterator will be generated if the argument is an array
or generator function. This allows certain functions to accept an array
or generator function interchangeably.