Releases: crystal-lang/crystal
Releases · crystal-lang/crystal
0.20.5
- Improved performance in
String#index
,String#rindex
due to Rabin-Karp algorithm (thanks @makenowjust). - Improved performance in
Crypto::Bcrypt
(see #3880, thanks @ysbaddaden). expect_raises
returns raised exception (thanks @kostya).- Line numbers debug information is always generated (see #3831, thanks @ysbaddaden).
- Added
Zip::File
,Zip::Reader
andZip::Writer
. Native readers for zip files that delegate compression to existing zlib module. - Added
Hash#delete
with block (see #3856, thanks @bmulvihill). - Added
String#[](char : Char)
(see #3855, thanks @Sija). - Added
crystal tool expand
to expand macro call in a given location (see #3732, thanks @makenowjust). - Fixed
crystal play
is able to show compilation errors again. crystal doc
recognizescrystal-lang/crystal
in any remote (thanks @MaxLap).- Some bug fixes
0.20.4
- (breaking change) A type that wants to convert itself to JSON now must override
to_json(builder : JSON::Builder)
instead ofto_json(io : IO)
. The same is true for custom JSON converters. If you are usingJSON.mapping
then your code will continue to work without changes. - (breaking change) Defining a
finalize
method on a struct now gives a compile error - (breaking change) Default argument types now must match their restriction, if any (for example
def foo(x : Int32 = nil)
will now fail to compile iffoo
is invoked without arguments) (thanks @makenowjust) - (breaking change)
each
methods now returnNil
- (breaking change)
IO#skip(bytes)
will now raise if there aren't at least the given amount of bytes in theIO
(previously it would work well if there were less bytes, and it would hang if there were more) - (breaking change)
MemoryIO
was removed (useIO::Memory
instead) - (breaking change)
Number#step
now requires named arguments,to
andby
, to avoid argument order confusion - (breaking change)
YAML::Emitter
was renamed toYAML::Builder
, and some of its methods were also renamed - (breaking change)
XML::Node#[]
now always returns aString
(previously it could also returnNil
, which was incorrect) - (breaking change)
XML::Node#content
now returns an emptyString
when no content is available HTTP::Client
now automatically reconnects on a dropped keep-alive connectionwith ... yield
now works well withmethod_missing
- Class variables can now be used in generic types (all generic instances share the same variable, and subclasses get their own copy, as usual)
- Added support for LLVM 4 (thanks @ysbaddaden)
- Added
Enum.each
andEnum#each
(thanks @ysbaddaden) - Added
Hash#compact
andHash#compact!
(thanks @makenowjust) - Added
IO#read_string(bytesize)
- Added
IO#skip_to_end
- Added
Iterator#flat_map
(thanks @makenowjust) - Added
JSON.build
andJSON::Builder
- Added
NamedTuple#has_key?(String)
(thanks @Sija) - Added
p(NamedTuple)
(thanks @splattael) - Added
Regex::MatchData#==
(thanks @makenowjust) - Added
String#sub(Regex, NamedTuple)
(thanks @maiha) - Added
XML.build
andXML::Builder
- Lots of improvements and applied consistencies to doc comments (thanks @Sija and @maiha)
- Some bug fixes
0.20.3
- (breaking change)
IO#gets
,IO#each_line
,String#lines
,String#each_line
, etc. now chomp lines by default. You can passchomp: false
to prevent automatic chomping. Note thatchomp
istrue
by default for arglessIO#gets
(read line) butfalse
if args are given. - (breaking change)
HTTP::Handler
is now a module instead of a class (thanks @andrewhamon) - (breaking change) Free variables now must be specified with
forall
, a single uppercase letter will not work anymore - (breaking change) The
libs
directory is no longer in the default CRYSTAL_PATH, uselib
(runningcrystal deps
should fix this) - Optimized compile times, specially on linux
private
can now be used with macros inside types (thanks @makenowjust)- CLI: the
-s
/--stats
option now also shows execution time (thanks @makenowjust) - CLI: added
-t
/--time
to show execution time (thanks @makenowjust) Socket
now allows any family/type/protocol association, and many other improvements (thanks @ysbaddaden)- YAML: an
IO
can now be passed tofrom_yaml
(thanks @makenowjust) - Added
class_getter
,class_setter
,class_property
, etc. (thanks @Sija) - Added
String#lchomp
(thanks @Sija) - Added
IO#read_fully?
- Added
Iterator#flatten
(thanks @makenowjust) - Added
HTTP::WebSocket#ping
,pong
,on_ping
,on_pong
, and now a ping message is automatically replied with a pong message (thanks @Sija) - Added
File#empty?
andDir#empty?
(thanks @dylandrop) - Added
Time::Span#/(Time::Span)
(thanks @RX14) - Added
String#split
versions that accept a block (thanks @splattael) - Added
URI#normalize
andnormalize!
(thanks @taylorfinnell) - Added
reuse
optional argument to manyArray
,Enumerable
andIterable
methods that allow you to reuse the yielded/return array for better performance and less memory footprint - The
:debug
flag is now present when compiled with--debug
, useful for doingflag?(:debug)
in macros (thanks @luislavena) - Many bug fixes and performance improvements
0.20.1
- (breaking change)
Set#merge
as renamed toSet#merge!
- (breaking change)
Slice.new(size)
no longer works with non primitive integers and floats - (breaking change) The macro method
argify
was renamed tosplat
- Added pretty printing. The methods
p
andpp
now use it. To get the old behaviour useputs obj.inspect
- Added
ArrayLiteral#[]=
,TypeNode#constant
,TypeNode#overrides?
andHashLiteral#double_splat
in macros - Added a
finished
macro hook that runs at the end of the program - Added support for declaring the type of a local variable
- Added
Slice.empty
- Flags enums now have a
none?
method IO::ByteFormat
has now methods to encode/decode to/from aSlice
- Spec: the line number passed to run a specific
it
block can now be inside any line of that block - The
CallConvention
attribute can now also be applied to alib
declaration, and allfun
s inside it will inherit it - The
method_missing
hook can now define a method, useful for specifying block arguments - Support double splat in macros (
{{**...}}
) - Some bug fixes
0.20.0
- (breaking change) Removed
ifdef
from the language - (breaking change) Removed
PointerIO
- (breaking change) The
body
property ofHTTP::Request
is now anIO?
(previously it wasString
). Userequest.body.try(&.gets_to_end)
if you need the entire body as a String. - (breaking change)
MemoryIO
has been renamed toIO::Memory
. The old name can still be used but will produce a compile-time warning.MemoryIO
will be removed immediately after 0.20.0. - (breaking change)
Char#digit?
was split intoChar#ascii_number?
andChar#number?
. The old name is still available and will produce a compile-time warning, but will be removed immediately after 0.20.0. - (breaking change)
Char#alpha?
was split intoChar#ascii_letter?
andChar#letter?
. The old name is still available and will produce a compile-time warning, but will be removed immediately after 0.20.0. - (breaking change) The
Iterable
module is now generic - Many
String
andChar
methods are now unicode-aware, for exampleString#downcase
,String#upcase
,Char#downcase
,Char#upcase
,Char#whitespace?
, etc. - Added support for HTTP client and server streaming.
- Added support for ARM (thanks @ysbaddaden)
- Added support for AArch64 (thanks @ysbaddaden)
- Added support for LLVM 3.9 (thanks @ysbaddaden)
- Added
__END_LINE__
magic constant in method default arguments: will be the last line of a call (if the call has a block, it will be the last line of that block) - Added
@def
inside macros that takes the value of the current method - API docs have a nicer style now, and notes like TODO and DEPRECATED are better highlighted (thanks @samueleaton)
- Slight improvement to debugging support (thanks @ggiraldez)
- Line numbers in backtraces (linux only for now) (thanks @ysbaddaden)
- Added iteration times to
Benchmark.ips
(thanks @RX14) - Allow
HTTP::Client
block initializer to be used when passing an URI (thanks @philnash) JSON.mapping
andYAML.mapping
getter/setter generation can now be controlled (thanks @zatherz)Time
is now serializable to JSON and YAML using ISO 8601 date-time format- Added
IO::MultiWriter
(thanks @RX14) - Added
String#index(Regex)
andString#rindex(Regex)
(thanks @zatherz) - Added
String#partition
andString#rpartition
(thanks @johnjansen) - Added
FileUtils.cd
,FileUtils.mkdir
,FileUtils.mkdir_p
,FileUtils.mv
,FileUtils.pwd
,FileUtils.rm
,FileUtils.rm_r
,FileUtils.rmdir
(thanks @ghivert) - Added
JSON::Builder#raw_field
(thanks @kostya) - Added
Enumerable#chunks
andIterator#chunk
(thanks @kostya) - Added
Iterator#with_index
- Several enhancements to the Random module: now works for any integer type and avoids overflows (thanks @BlaXpirit)
- Optimized
Array#sort
by using introsort (thanks @c910335) - Several bug fixes
0.19.4
- Added support for OpenBSD (thanks @wmoxam and @ysbaddaden)
- More iconv fixes for FreeBSD (thanks @ysbaddaden)
- Changed how
require
works for the upcomingshards
release (this is backwards compatible). See #2788 - Added
Atomic
and exposed all LLVM atomic instructions to Crystal (needed to implemented multiple-thread support) - Added
Process.executable_path
(thanks @kostya, @whereami and @ysbaddaden) - Added
HTML.unescape
(thanks @dukex) - Added
Char#+(Int)
andChar#-(Int)
- A few bug fixes
0.19.3
crystal eval
now accepts some flags like--stats
,--release
and--help
- Added
File.chown
andFile.chmod
(thanks @ysbaddaden) - Added
Time::Span.zero
(useful for doingsum
) (thanks @RX14) - Added docs to
OAuth
andOAuth2
- Several bug fixes
0.19.2
- Generic type variables no longer need to be single-letter names (for example
class Gen(Foo)
is now possible) - Added syntax to denote free variables:
def foo(x : T) forall T
. The old rule of single-letter name still applies but will be removed in the future. - Removed the restriction that top-level types and constants can't have single-letter names
- Added
@[Extern]
attribute to mark regular Crystal structs as being able to be used in C bindings - Faster
Char#to_s
when it's ASCII: this improves the performance of JSON and CSV parsing crystal spec
: allow passing--release
and other optionscrystal spec
: allow running all specs in a given directorycrystal playground
: support custom workbook resources (thanks @bcardiff)crystal playground
: standard output now understands ANSI colors (thanks @bcardiff)- Added many more macro methods to traverse AST nodes (thanks @BlaXpirit)
- Error messages no longer include a type trace by default, pass
--error-trace
to show the full trace (the trace is often useless and makes it harder to understand error messages) - Several bug fixes
0.19.1
0.19.0
- (breaking change) Added
select
keyword - (breaking change) Removed $global variables. Use @@Class variables instead.
- (breaking change) Heredoc now ends when the matching identifier is found, either followed by a space or by a non-identifier
- (breaking change) Assignment to a local variable inside an assignment to that same variable is now an error
- (breaking change) Type names like
T
,T1
,U
, etc., are now disallowed at the top level, to avoid conflicts with free variables - (breaking change) Type lookup (
Foo::Bar::Baz
) had some incorrect behaviour that now is fixed. This can break existing code that relied on this incorrect behaviour. The fix is to fully qualify types (::Foo::Bar::Baz
) - (breaking change) In relationships like
class Bar < Foo(Baz)
andinclude Moo(Baz)
, all ofFoo
,Moo
andBaz
must be defined before that point (this was not always the case in previous versions) - (breaking change) Removed the deprecated syntax
x as T
- (breaking change) Removed block form of
String#match
- (breaking change) Removed
IO#read_nonblock
- (breaking change)
Int#/
now performs floored division. UseInt#tdiv
for truncated division (see their docs to learn the difference) - Added support for LLVM 3.8 (thanks @omarroth)
||
now does type filtering- Generic inheritance should now work well, and (instantiated) generic modules can now be used as the type of instance variables
NamedTuple
can now be accessed with strings too (thanks @jhass)Base64
can now encode and decode directly to anIO
(thanks @kostya)BigInt
now uses GMP implementation of gcd and lcm (thanks @endSly)ECR
now supports removing leading and trailing whitespace (<%-
,-%>
)HTTP::Request#path
now never returnsnil
: it fallbacks to"/"
(thanks @jhass)String#tr(..., "")
is now the same asString#delete
tool hierarchy
now supports--format json
(thanks @bmulvihill)- Added
Char#ascii?
- Added
Class#nilable?
andUnion#nilable?
- Added
Hash#has_value?
(thanks @kachick) - Added
IO::Sized
andIO::Delimited
(thanks @RX14) - Added
IO::Hexdump
(thanks @ysbaddaden) - Added
IO#noecho
andIO#noecho!
(thanks @jhass) - Added
Logger.new(nil)
to create a null logger - Added
OptionParser#missing_option
andOptionParser#invalid_option
(thanks @jhass) - Added
Process.exists?
,Process#exists?
andProcess#terminated?
(thanks @jhass) - Added
Process.exec
(thanks @jhass) - Added
Slice#copy_to
,Slice#copy_from
,Slice#move_to
andSlice#move_from
(thanks @RX14) - Added
URI#==
andURI#hash
(thanks @timcraft) - Added
YAML#parse(IO)
- Added
Indexable
module thatArray
,Slice
,Tuple
andStaticArray
include - Added
indent
parameter toto_pretty_json
- Added lazy form of
getter
andproperty
macros - Added macro methods to access an ASTNode's location
- Unified String and Char to integer/float conversion API (thanks @jhass)
- Lots of bug fixes