Releases: crystal-lang/crystal
Releases · crystal-lang/crystal
0.17.0
- (breaking change) Macro defs are now parsed like regular methods. Enclose the body with
{% begin %} .. {% end %}
if you needed that behaviour - (breaking change) A union of two tuples of the same size results in a tuple with the unions of the types in each position. This only affects code that later tested a tuple's type with
is_a?
, for exampletuple.is_a?({Int32, String})
- (breaking change) Method arguments have now a different semantic. This only affects methods that had a splat argument followed by other arguments.
- (breaking change) The syntax
{foo: 1, bar: 2}
now denotes aNamedTuple
, not aHash
with symbol as keys. Use{:foo => 1, :bar => 2}
instead - The syntax
exp as Type
is now deprecated and will be removed in the next version. Usecrystal tool format
to automatically upgrade your code - The compiler now gives an error when trying to define a method named
!
,is_a?
,responds_to?
,nil?
,as
oras?
- Added the
NamedTuple
type - Added double splatting
- Added external argument names
- Macro defs return type is no longer mandatory
- Added
as?
: similar toas
, but returnsnil
when the type doesn't match - Added
Number::Primitive
alias - Added
Tuple#+(Tuple)
- Added
ArrayLiteral#+(ArrayLiteral)
in macros Crypto::MD5
now allowsSlice(UInt8)
and a block form (thanks @will)- Added docs for XML (thanks @Hamdiakoguz)
- Many bug fixes
0.16.0
- (breaking change) Instance, class and global variables types must be told to the compiler, either explicitly or through a series of syntactic rules
- (breaking change) Non-abstract structs cannot be inherited anymore (abstract structs can), check the docs to know why. In many cases you can use modules instead.
- (breaking change) Class variables are now initialized at the beginning of the program (before "main"), make sure to read the docs about class variables and main
- (breaking change) Constants are now initialized at the beginning of the program (before "main"), make sure to read the docs about constants and main
- (breaking change) When doing
crystal program.cr arg1 arg2 arg3
,arg1
,arg2
andarg3
are considered arguments to pass to the program (not the compiler). Usecrystal run program.cr arg1 ...
to considerarg1
a file to include in the compilation. - (breaking change)
Int#**(Int)
now returns an integer, and raises if the argument is negative. Use a float base or exponent for negative exponents to work. - (breaking change)
Slice#to_s
andStaticArray#to_s
now include their type name in the output - Support for FreeBSD and musl libc has landed (thanks @ysbaddaden)
- The
.crystal
directory is now created at$HOME/cache/.crystal
or$HOME/.crystal
(or others similar), with a fallback to the current directory crystal doc
andcrystal tool hierarchy
are now much faster. Additionally, the hierarchy tool shows types for generic types, and doesn't show instantiations anymore (wasn't very useful)!
now does type filtering (for example you can do!x || x.bar
, assumingx
can benil
and the non-nil type responds tobar
)- Named arguments can now match any argument, even if they don't have a default value. Make sure to read the docs
- The
as
operator can now be written as a method:exp.as(Type)
in addition toexp as Type
. The old syntax will be removed in a few releases. - Added
@x : Int32 = 1
syntax (declaration + initialization) new
/initialize
logic now works more as one would expect- Added
BigRational
(thanks @will) - Added
BigFloat
(thanks @exilor) - Added
String#insert
- Added
Time::EpochConverter
andTime::EpochMillisConverter
- Added
%s
(unix epoch) directive toTime::Format
Time
now honours Dayling Saving andENV["TZ"]
- Added
HTTP::Server::Response#cookies
(thanks @jhass) - Added
Array#bsearch
,Array#bsearch_index
andRange#bsearch
(thanks @makenowjust) - Added
Range#reverse_each
iterator (thanks @omninonsense) JSON::Any
: addedas_...?
methods (thanks @DougEverly)JSON::Any
is nowEnumerable
YAML::Any
is nowEnumerable
- Added
JSON.parse_raw
that returns aJSON::Type
JSON::PullParser
: added#read_raw
to read a JSON value as a raw string (useful for delayed parsing). Also addedString::RawConverter
to be used withJSON.mapping
.JSON
andYAML
: enums,BigInt
andBigFloat
are now serializableENV
: allow passingnil
as a value to delete an environment variableHash
: allowArray | Tuple
arguments for#select
,#select!
,#reject
and#reject!
Crypto::Subtle.constant_time_compare
now returnsBool
, and it can compare two strings in addition to two slices (thanks @skunkworker)HTTP::Server
: reset port zero after listening (thanks @splattael)- Added
File#each_line
iterator - Added
Number.slice
,Number.static_array
,Slice.[]
andStaticArray.[]
to easily create slices and static arrays - Added
Slice#hexdump
(thanks @will) - Added
Enumerable#product
(thanks @dkhofer) - Fix: disallow using
out
withVoid*
pointers - Fixed bug in
XML::Node#namespace_scopes
(thanks @Hamdiakoguz) - Added docs for
INIFile
(thanks @EvanHahn) - Lots of bug fixes
0.15.0
- (breaking change)
!
has now its meaning hardcoded in the language. If you defined it for a type it won't be invoked as a method anymore. - (breaking change)
nil?
has now its meaning hardcoded in the language. If you defined it for a type it won't be invoked as a method anymore. - (breaking change)
typeof
is now disallowed inalias
declarations - Added
crystal tool format --check
to check that source code is properly formatted crystal play
(playground) added workbooks support, as well as improvements and stabilizations- Added
Tempfile.dirname
(thanks @DougEverly) - Added
Path#resolve
method in macros {{...}}
arguments to a macro call are now expanded before macro invocation (#2392)- Special variables (
$~
and$?
) are now accessible after being defined in blocks (#2194) - Some bugs and regressions fixed
0.14.2
0.14.1
0.14.1 (2016-03-21)
- Fixed some regressions in the formatter
0.14.0 (2016-03-21)
- (breaking change) The syntax of a method argument with a default value and a type restriction is now
def foo(arg : Type = default_value)
. Runcrystal tool format
to automatically upgrade exsiting code to this new syntax. The olddef foo(arg = default_value : Type)
was removed. - (breaking change)
Enumerable#take(n)
andIterator#take(n)
were renamed tofirst(n)
- (breaking change)
Socket#addr
andSocket#peeraddr
were renamed tolocal_address
andremote_address
respectively - (breaking change) Removed
Comparable#between?(a, z)
. Usea <= x <= z
instead - (breaking change)
HTTP::WebSocketHandler
callbacks can now access theHTTP::Context
. If you had a forwarding method to it you'll need to update it. See #2313. - New command
crystal play
that opens a playground for you to play in the browser :-) (thanks @bcardiff) - New command
crystal env
that prints environment information Spec
: you can now run multiple files with specified line numbers, as incrystal spec file1.cr:10 file2.cr:20 ...
- Initial support for musl-libc (thanks @ysbaddaden)
- Added
FileUtils.cp
(thanks @Dreauw) - Added
Array#first(n)
andArray#last(n)
(thanks @greyblake) - Added
WebSocket#close
and properly handle disconnections - Added
UDPSocket#send
andUDPSocket#receive
(thanks @tatey) - Added
Char#uppercase?
andChar#lowercase?
(thanks @MaloJaffre`) - Added
sync_close
property toOpenSSL::SSL::Socket
,Zlib::Inflate
andZlib::Deflate
- Added
XML::Node#encoding
andXML::Node#version
- Added
HTTP::Client::Response#success?
(thanks @marceloboeira) - Added
StaticArray#shuffle!(random)
(thanks @Nesqwik) - Added
Splat#exp
method in macros - Added fiber-safe
Mutex
- All
Int
types (exceptBigInt
) can now be used inJSON
andYAML
mappings (thanks @marceloboeira) - Instance variable declarations/initializations now correctly work in generic classes and modules
- Lots of bug fixes
0.14.0
- (breaking change) The syntax of a method argument with a default value and a type restriction is now
def foo(arg : Type = default_value)
. The olddef foo(arg = default_value : Type)
was removed. - (breaking change)
Enumerable#take(n)
andIterator#take(n)
were renamed tofirst(n)
- (breaking change)
Socket#addr
andSocket#peeraddr
were renamed tolocal_address
andremote_address
respectively - (breaking change) Removed
Comparable#between?(a, z)
. Usea <= x <= z
instead - (breaking change)
HTTP::WebSocketHandler
callbacks can now access theHTTP::Context
. If you had a forwarding method to it you'll need to update it. See #2313. - New command
crystal play
that opens a playground for you to play in the browser :-) (thanks @bcardiff) - New command
crystal env
that prints environment information Spec
: you can now run multiple files with specified line numbers, as incrystal spec file1.cr:10 file2.cr:20 ...
- Initial support for musl-libc (thanks @ysbaddaden)
- Added
FileUtils.cp
(thanks @Dreauw) - Added
Array#first(n)
andArray#last(n)
(thanks @greyblake) - Added
WebSocket#close
and properly handle disconnections - Added
UDPSocket#send
andUDPSocket#receive
(thanks @tatey) - Added
Char#uppercase?
andChar#lowercase?
(thanks @MaloJaffre`) - Added
sync_close
property toOpenSSL::SSL::Socket
,Zlib::Inflate
andZlib::Deflate
- Added
XML::Node#encoding
andXML::Node#version
- Added
HTTP::Client::Response#success?
(thanks @marceloboeira) - Added
StaticArray#shuffle!(random)
(thanks @Nesqwik) - Added
Splat#exp
method in macros - Added fiber-safe
Mutex
- All
Int
types (exceptBigInt
) can now be used inJSON
andYAML
mappings (thanks @marceloboeira) - Instance variable declarations/initializations now correctly work in generic classes and modules
- Lots of bug fixes
0.13.0
- (breaking change)
Matrix
was moved to a separate shard: https://github.com/Exilor/matrix - The syntax of a method argument with a default value and a type restriction is now
def foo(arg : Type = default_value)
. Runcrystal tool format
to automatically upgrade exsiting code to this new syntax. The olddef foo(arg = default_value : Type)
syntax will be removed in a next release. - Special handling of
case
with a tuple literal. See #2258. - Keywords can now be used for variable declaration, so
property end : Time
works as expected. - Comparison of signed vs. unsigned integers now always give a correct result
- Allow declaring instance variables in non-generic module types (
module Moo; @x : Int32; end
) - Allow initializing instance variables in non-generic module types (
module Moo; @x = 1; end
) Spec
: allow setting multiple output formatters (thanks @marceloboeira)StringScanner
: improved performance- Added
foo.[0] = 1
andfoo.[0]
as valid syntax, similar to the one in&.
blocks (thanks @makenowjust) CSV
: allow separate and quote characters different than comma and doble quote (thanks @jreinert)YAML
: support merge operator (<<
) (thanks @jreinert)- Allow redefining primitive methods like
Int32#+(other : Int32)
- Allow defining macros with operator names like
[]
Levenshtein
: improved performance (thanks @tcrouch)HTTP::Client
: fixed incorrect parsing of chunked bodyHTTP::Client
: added a constructor with anURI
argument (thanks @plukevdh)String
:sub
andgsub
now understand backreferences (thanks @bjmllr)Random
: addedRandom#rand(Float64)
andRandom#rand(Range(Float, Float))
(thanks @AlexWayfer)HTML
:HTLM.escape
includes more characters (thanks @Ryuuzakis)- Added
TypeNode.class
method in macros (thanks @waterlink) run
inside macros now also work with absolute paths (useful when used with__DIR__
)- Added docs for
Math
andStaticArray
(thanks @zavydiel, @HeleneMyr) - Many bug fixes and some micro-optimizations
0.12.0
- (breaking change) When used with a type declaration, the macros
property
,getter
,setter
, etc., declare instance variables with those types. - (breaking change)
JSON.mapping
andYAML.mapping
declare instance variables with the given types. - (breaking change)
YAML.load
was renamed toYAML.parse
, and it now returns aYAML::Any
. - (breaking change)
embed_ecr
andecr_file
were renamed toECR.embed
andECR.def_to_s
(the old methods now produce a warning and will be removed in the next release). - Added encoding support:
IO#set_encoding
,String#encode
, andHTTP::Client
charset check. - Segmentation faults are now trapped and shown in a more friendlier way.
- The
record
macro can now accept type declarations (for examplerecord Point, x : Int32, y : Int32
) - Added
Iterator#step
(thanks @jhass) Array#push
andArray#unshift
can now accept multiple values and add the elements in an efficient way (thanks @arktisklada)- Added
default
option toJSON.mapping
(thanks @kostya) - Added
default
option toYAML.mapping
(thanks @jreinert) - Allow doing
case foo; when Foo.class
(andFoo(T)
andFoo(T).class
) in case expressions. - Added
Class#|
so a union type can be expresses asInt32 | Char
in regular code. - Added
File.real_path
(thanks @jreinert) - Added
dns_timeout
forHTTP::Client
(thanks @kostya) - Added dynamic width precision to
sprintf
(thanks @gtramontina) Markdown
now supports blockquotes and 1 level of list nesting (thanks @SebastianSzturo)p
now accepts multiple arguments- Many bug fixes and some optimizations
0.11.1
0.11.0
- (breaking change) Syntax for type declarations changed from
var :: Type
tovar : Type
. The old syntax is still allowed but will be deprecated in the next version (runcrystal tool format
to automatically fix this) - (breaking change) Syntax for uninitialized variables, which used to be
var :: Type
, is nowvar = uninitialized Type
. The old syntax is still allowed but will be deprecated in the next version (runcrystal tool format
to automatically fix this) - (breaking change)
HTTP::Server
refactor to support streaming. Check the docs ofHTTP::Server
for upgrade instructions - (breaking change) Renamed
HTTP::WebSocketSession
toHTTP::WebSocket
. - (breaking change) Heredocs now remove indentations according to the indentation of the closing identifier (thanks @rhysd)
- (breaking change) Renamed
Enumerable#inject
toEnumerable#reduce
- (breaking change)
next
andreturn
semantic inside captured block has been swapped (#420) - Fibers context switch is now faster, done with inline assembly.
libpcl
is no longer used - Allow annotating the type of class and global variables
- Support comments in ECR (thanks @ysbaddaden)
- Security improvements to
HTTP::StaticFileHandler
(thanks @makenowjust) - Moved
seek
,tell
,pos
andpos=
fromFile
toIO::FileDescriptor
(affectsTempfile
) URI.parse
is now faster (thanks @will)- Many bug fixes, some really old ones involving issues with order of declaration