- Docs search now finds nested entries (thanks @adlerhsieh)
- Many corrections and changes to the formatter, for better consistency and less obtrusion.
- Added
OpenSSL::CipherandOpenSSL::Digest(thanks @benoist) - Added
Char#+(String)(thanks @hangyas) - Added
Hash#keyandHash#key?(thanks @adlerhsieh) - Added
Time::Span#*andTime::Span#/(thanks @jbaum98) - Added
Slice#reverse_each(thanks @omninonsense) - Added docs for
RandomandTempfile(thanks @adlerhsieh) - Fixed some bugs.
- (breaking change) The
CGImodule's funcionality has been moved toURIandHTTP::Params - (breaking change)
IO#read()is nowIO#gets_to_end. RemovedIO#read(count), addedIO#skip(count) - (breaking change)
json_mappingis nowJSON.mapping.yaml_mappingis nowYAML.mapping - (breaking change)
StringIOis nowMemoryIO - Added
crystal tool formatthat automatically formats your code protectedmethods can now be invoked between types inside a same namespace- Removed
curses, you can usehttps://github.com/jreinert/ncurses-crystal to_unsafeand numeric conversions are now also automatically performed in C struct and union fields- Added
{% begin %} ... {% end %}as an alternative to{% if true %} ... {% end %} - Added
~!operator - Added debug metadata for char, float, bool and enums. Also for classes and structs (experimental)
Dir.globnow works well with recursive patterns like**(thanks @pgkos)- Added
read_timeoutandconnect_timeouttoHTTP::Client(thanks @benoist) - Added
Zlib(thanks @datanoise and @bcardiff) - Added
HTTP::DeflateHandler(thanks @bcardiff) - Added
ENV#fetch(thanks @tristil) Hash#newnow accepts an initialize capacity argumentHTTP::Requestprovides access and mutation ofquery,pathandquery_params(thanks @waterlink)- Added
XML::Node#content=and#name= - Allow passing handlers and a block to an
HTTP::Server(thanks @RX14) crystal initnow tries to use your github username if available (thanks @jreinert)- Added
Hash#select,Hash#rejectand their bang variant, andHash#each_with_object(thanks @devdazed) - Added
Hash#select(*keys)andHash#reject(*keys)and their bang variant (thanks @sdogruyol) - Added
Set#-,Set#^, andSet#subtract(thanks @js-ojus) - Allow running specs without colors (thanks @rhysd)
- Added
TypeNode#has_constant?andTypeNode#type_varsin macros (thanks @jreinert) - Added
String#comparethat allows case insensitive comparisons - Added
File#truncate(thanks @porras) CSVis now a class for iterating rows, optionally with headers access- Allow setting multiple
before_requestcallbacks to anHTTP::Client - Added
Dir.cd(&block)(thanks @rhysd) - Added
Class#cast(thanks @will) - Fixes and additions to WebSocket, like the possibility of streaming data (thanks @jreinert)
- Added
SemanticVersionclass (thanks @technorama) loopnow yields a counter- Added
Array#[]=(index, count, value)andArray#[]=(range, value) - Added argless
sleep IO#write(slice)now writes the full slice or raises on error- Added some docs for ECR, Markdown, Hash, File, Time, Time::Span, Colorize, String, SecureRandom, YAML (thanks @adlerhsieh, @chdorner, @vjdhama, @rmosolgo)
- Many bug fixes
- (breaking change) Renamed a couple of types:
ChannelClosed->Channel::ClosedError,UnbufferedChannel->Channel::Unbuffered,BufferedChannel->Channel::Buffered,DayOfWeek->Time::DayOfWeek,MonthSpan->Time::MonthSpan,TimeSpan->Time::Span,TimeFormat->Time::Format,EmptyEnumerable->Enumerable::EmptyError,SocketError->Socket::Error,MatchData->Regex::MatchData,SignedInt->Int::Signed,UnsignedInt->Int::Unsigned,FileDescriptorIO->IO::FileDescriptor,BufferedIO->IO::Buffered,CharReader->Char::Reader,PointerAppender->Pointer::Appender. - (breaking change) All places that raised
DomainErrorraiseArgumentErrornow. - (breaking change) Renamed
Type.casttoType.new(for example,Int32.newinstead ofInt32.cast) - (breaking change) Removed all macro instance variables except
@type - (breaking change) Removed
undef - (breaking change) Removed
length()andcount()methods from collections. The only method for this is nowsize. - (breaking change) Removed the ability to invoke methods on a union class
- Improved debugger support
crystal depsnow delegates to shards. RemovedProjecfilesupport.- Automatically convert numeric types when invoking C functions
- Automatically define questions methods for enum members
- Support quotes inside quoted symbols (thanks @wolflee)
- Allow marking
initializeas private - Added
method_addedmacro hook (thanks @MakeNowJust) - Added
ArrayLiteral#includes?(obj)in macros - Added
ASTNode#symbolizein macros (thanks @kirbyfan64) - Added experimental
yaml_mapping - Added nilable variants to
Enumerable#max,Enumerable#min, and others (thanks @technorama) - Added
Iterator#flatten(thanks @jpellerin) - Added setting a read timeout to
HTTP::Client(thanks @benoist) - Added
Array#delete_at(index, count)andArray#delete_at(range)(thanks @tebakane) - Added
HTTP::Cookies(thanks @netfeed) - Added
Tuple#reverse(thanks @jhass) - Added
Number#clamp(thanks @technorama) - Added serveral socket options (thanks @technorama)
- Added
WebSocket.open(thanks @kumpelblase2) - Added
Enum.flagsmacro - Added support for sending chunked content in HTTP server (thanks @bcardiff)
- Added
future,lazyanddelayconcurrency methods (thanks @technorama) forknow returns aProcess(thanks @technorama)- Documented
Set, and added a couple of methods (thanks @will) - Nicer formatting in
Benchmark.ips, and interactive mode (thanks @will) - The
-fformat output is now honored in compiler errors (thanks @kirbyfan64) - Fixed an ambiguity with the
crystal buildcommand (thanks @MakeNowJust) - Cast exceptions now raise
TypeCastErrorinstead ofException(thanks @will) - Many bugs fixes
- (breaking change) Reimplemented
Process.runto allow configuring input, output and error, as well as behaving well regarding non-blocking IO (thanks @technorama) - (breaking change) Removed the
alias_methodmacro. - (breaking change) Disallow declaring defs, classes and other declarations "dynamically" (for example inside an
if... this of course didn't work, but incorrectly compiled). - (breaking change)
requireis now only allowed at the top-level, never inside other types or methods. - (breaking change) Removed
Nil#to_i - (breaking change) Changed API of
Channel#selecttoward a thread-safe one. - (breaking change) The two methods that IO must implement are now
read(slice : Slice(UInt8))andwrite(slice : Slice(UInt8)). - New beautiful, searchable and more functional API docs. Thanks @rosylilly for the initial design, and @BlaxPirit for some improvements.
- CLI: Moved
browser,hierarchyandtypestocrystal tool ... - Added
crystal tool contextandcrystal tool implementationsfor IDEs (thanks @bcardiff!!) Int#>>(amount)andInt#<<(amount)now give zero whenamountis greater than the number of bits of the integer representation.- Added
\%escape sequence inside macros. - Added aliases for the many C types (thanks @BlaxPirit)
- Added
Iterator#in_groups_of(thanks @PragTob) - Added optional
offsetargument toHash#each_with_index(thanks @sergey-kucher) - Added
Array#combinations,Array#each_combination,Array#repeated_combinations,Array#each_repeated_combination,Array#repeated_permutations,Array#each_repeated_permutation,Array.productandArray.each_product(thanks @kostya) - Added
Array#rotateandArray#rotate!(thanks @kostya) - Added
MatchData#pre_matchandMatchData#post_match(thanks @bjmllr) - Added
Array#flatten - Added
Range.reverse_each, along withInt#predandChar#pred(thanks @BlaxPirit) - Added
XML.parse_html(thanks @ryanworl) - Added
ENV.keysandENV.values(thanks @will) - Added
StaticArray==(other : StaticArray)(thanks @tatey) - Added
String#subin many variants (thanks @jhass) - Added
Readline.bind_key,Readline.unbind_key,Readline.doneandReadline.done=(thanks @daphee) - Added
Hash#all?,Hash#any?andHash#inject(thanks @jreinert) - Added
File#posandFile#pos= - Added
Enum.from_valueandEnum.from_value? - Added
Deque(thanks @BlaxPirit) - Added lots of methods to
StringScanner, and documented it, making it usable (thanks @will) StringIOnow quacks like aFile.- Allow sending masked data through a
WebSocket, and sending long data (thanks @kumpelblase2) File.newnow accepts an optionalpermargument (thanks @technorama)FileDescriptorIOnow has configurable read/write timeouts (thanks @technorama)- Signal handling is more robust and allows any kind of code (thanks @technorama)
- Correctly handle
WebSocketclose packet (thanks @bebac) - Correctly implement
seekandtellin buffered IOs (thanks @lbguilherme) - Allow setting several options on sockets (thanks @technorama)
- Some improvements to
crystal initfor the "app" case (thanks @krisleech) sleepand IO timeouts can receiveTimeSpanas arguments (thanks @BlaxPirit)- Handle
HTTP::Responsewithout content-length (thanks @lbguilherme) - Added docs for OptionParser, ENV, Regex, Enumerable, Iterator and some Array methods (thanks @porras, @will, @bjmllr, @PragTob, @decioferreira)
- Lots of bug fixes and small improvements
- (breaking change) removed support for trailing
while/until(read this) - (breaking change) Renamed
Enumerable#droptoEnumerable#skip - (breaking change) Renamed
Time.attoTime.epoch, andTime#to_iandTime#to_ftoTime#epochandTime#epoch_f - (breaking change)
inheritedmacro now runs before a class' body - Renamed
--no-buildflag to--no-codegen - Allow interpolations in heredocs (thanks @jessedoyle)
- Allow hash substitutions in
String#%andsprintf(thanks @zamith) - Added
SecureRandom.base64,SecureRandom.urlsafe_base64andSecureRandom.uuid(thanks @ysbaddaden) - Added
File.link,File.symlinkandFile.symlink?(thanks @ysbaddaden) - Added
Enumerable#in_groups_of(thanks @jalyna) - Added
Array#zip?(thanks @yui-knk) - Added
Array#permutationsandArray#each_permutation(thanks @jalyna and @kostya) - Added
IO#gets(limit : Int)andIO#gets(delimiter : Char, limit : Int) - Added
Iterator#compact_map,Iterator#take_whileandIterator#skip_while(thanks @PragTob) - Added
StringLiteral#to_imacro method - Added
Crypto::Bcrypt(thanks @akaufmann) - Added
Time.epoch_msandTime#epoch_ms - Added
BitArray#toggleandBitArray#invert(thanks @will) - Fixed
IO#reopenswapped semantic (thanks @technorama) - Many bug fixes and improvements
- (breaking change)
0is not a prefix for octal numbers anymore. Use0o - (breaking change) Renamed
MissingKeytoKeyError - (breaking change) Renamed
IndexOutOfBoundstoIndexError - Fixed all exception-handling related bugs.
- Allow nested and multiline ternary expressions (thanks @daviswahl)
- Allow assigning to
_(underscore), give error when trying to read from it - Macros can now also receive the following nodes:
And,Or,Case,RangeLiteralandStringInterpolation.AndandOrhaveleftandrightmethods. - Added
-eoption tohierarchycommand to filter types by a regex - Added
-vas an alias of--version - Added
-has an alias of--help - Added
Array#transpose(thanks @rhysd) - Added
Benchmark#ips(thanks @will) - Added
Hash#merge(&block)andHash#merge!(&block)(thanks @yui-knk) - Added
Hash#invert(thanks @yui-knk) - Added
Bool#^(thanks @yui-knk) - Added
Enumerable#drop,Enumerable#drop_whileandEnumerable#take_while(thanks @PragTob) - Added
Enumerable#none?(thanks @yui-knk) - Added
Set#subset?,Set#superset?andSet#intersects?(thanks @yui-knk) - Added
Set#new(Enumerable)(thanks @yui-knk) - Added
String#succ(thanks @porras and @Exilor) - Added
Array#*(thanks @porras) - Added
Char#===(Int)andInt#===(Char)(thanks @will) - Added
StringLiteral#camelcaseandStringLiteral#underscorein macros - Added
Expressions#expressionsin macros - Added
Cast#objandCast#toin macros - Added
ASTNode#class_namein macros (thanks @yui-knk) - Added
Array#push/Array#<<andArray#unshiftin macros (thanks @ysbaddaden) - Added
Def#visibilityin macros (thanks @ysbaddaden) - Added
String#codepointsandString#each_codepoint(thanks @jhass) Char#to_i(base)now supports bases from 2 to 36
- Flush
STDERRon exit (thanks @jbbarth) HTTP::Clientmethods accept an optional block, which will yield anHTTP::Responsewith a non-nilbody_ioproperty to consume the response's IO- Document
URI,UDPSocket(thanks @davydovanton) - Improved
URIclass (thanks @will) - Define
$~inString#gsubandString#scan - Define
$?inProcess.run - Lots of bug fixes and small improvements
- Added Float module and remainder (thanks @wmoxam)
- Show elapsed time in HTTP::LogHandler (thanks @zamith for the suggestion)
- Added
0oas a prefix for octal numbers (thanks @asb) - Allow spaces before the closing tag of a heredoc (thanks @zamith)
String#split(Regex)now includes captures in the results- Added
union?,union_typesandtype_paramsin macro methods - Improved
MatchData#to_sto show named groups (thanks @will) - Optimized Base64 encode/decode (thanks @kostya)
- Added basic docs for spec (thanks @PragTob)
- Added docs for Benchmark (thanks @daneb)
- Added
ARGF - Non-matching regex captures now return
nilinstead of an empty string (thanks @will) - Added
$1?,$2?, etc., as a nilable alternative to$1,$2, etc. - Added user, password, fragment and opaque to URI (thanks @will)
HTTP::Client.execnow honors user/password info from URI- Set default user agent in
HTTP::Client - Added
String#chop - Fixed
crystal depsbehaviour with empty git repositories (thanks @tkrajcar) - Optimized
HTTP::HeadersandHTTP::Requestparsing. FileDescriptorIO(superclass ofFileandSocket) has now buffering capabilities (usesync=andsync?to turn on/off). That means there's no need to useBufferedIOfor these classes anymore.- Allow
pointerofwith class and global variables, and alsofoo.@baraccess - Optimized fibers performance.
- Added inline assembly support.
- The
.crystalcache dir is now configurable with an ENV variable (thanks @jhass) - Generic type variables names can now also be a single letter followed by a digit.
- Added
Tuple.from_jsonandTuple.to_json - The
method_missingmacro now accepts a 1 argument variant that is a Call node. The 3 arguments variant will be deprecated. - Flush STDOUT at program exit (fixes
printnot showing any output) - Added
Time#to_utcandTime#to_local(thanks @datanoise) - Time comparison is now correct when comparing local vs. utc times
- Support timezone offsets in Time parsing and formatting
- Added
IO#gets(delimiter : String) - Added
String#chomp(Char)andString#chomp(String) - Allow invoking
debug()inside a macro to see what's being generated. IO#putsandIO#printnow receive a splat (thanks @rhysd)- Added
Process.killandProcess.getpgid(thanks @barachy) Signalis now an enum. Use it likeSignal::INT.trap { ... }instead ofSignal.trap(Signal::INT) { ... }- Added
CSV.each_row(both in block and iterator forms) - Important fixes to non-blocking IO logic.
- Improved performance of Regex
- Fixed lexing of octal characters and strings (thanks @rhysd)
- Time.parse can return UTC times (thanks @will)
- Handle dashes in
crystal init(thanks @niftyn8) - Generic type varaibles can now only be single letters (T, U, A, B, etc.)
- Support
%xand%Xinsprintf(thanks @yyyc514) - Optimized
Int#to_s(thanks @yyyc514) - Added
upcaseoption toInt#to_s, and use downcase by default. - Improved
String#to_iand fixed the many variants (to_i8,to_u64, etc.) - Added
Time.at(thanks @jeromegn) - Added
Int#upto,Int#downto,Int#toiterators. - Added
Iterator#consandEnumerable#each_cons(thanks @porras) - Added
Iterator.of,Iterator#chainandIterator#tap. - Allow top-level
private macro(similar to top-levelprivate def) - Optimized
BufferedIOwriting performance and memory usage. - Added
Channel#close,Channel#closed?,Channel#receive?and allow them to send/receive nil values (thanks @datanoise). - Fixed
Process#runafter introducing non-blocking IO (thanks @will) Tuple#mapnow returns aTuple(previously it returned anArray)Tuple#classnow returns a properClass(previously it returned aTupleof classes)- Lots of bug fixes.
- Crystal has evented IO by default. Added
spawnandChannel. - Correctly support the X86_64 and X86 ABIs. Now bindings to C APIs that pass and return structs works perfectly fine.
- Added
crystal initto quickly create a skeleton library or application (thanks @waterlink) - Added
--emitflag to the compiler. Now you can easily see the generated LLVM IR, LLVM bitcode, assembly and object files. - Added
--no-colorflag to supress color output, useful for editor tools. - Added macro vars:
%varand%var{x, y}create uniqely named variables inside macros. - Added typed splats.
- Added
Iteratorand many methods that return iterators, likeArray#each,Hash#each,Int#times,Int#step,String#each_char, etc. - Added
sprintfand improvedString#%to support floats and float formatting. - Added more variants of
String#gsub. - Added
Pointer#clearand use it to clear anArray's values when doingpopand other shrinking methods. - Added
BigInt#to_s(base),BigInt::castand bit operators (thanks @Exilor) - Allow invoking methods on a union class as long as all types in the union have it.
- Allow specifying a def's return type. The compiler checks the return type only for that def for now (not for subclasses overrding the method). The return type appears in the documentation.
- Allow constants and computed constants for a StaticArray length.
- Allow class vars in enums.
- Allow private and protected defs in enums.
- Allow reopening a
liband adding more@[Link]attributes to it, even allowing duplicated attributes. - Allow getting a function pointer to a lib fun without specifying its types (i.e.
->LibC.getenv) - Allow specifying
dittofor a doc comment to reuse the previous comment. - Changed the semantic of
%: previously it meantremainder, not it meansmodulo, similar to Ruby and Python. AddedInt#remainder. #to_sand#inspectnow work for a union class.- Spec: added global
before_eachandafter_eachhooks, which will simplify the use of mocking libraries like timecop.cr and webmock.cr. Range(T)is nowRange(B, E)again (much more flexible).- Improved Regex performance.
- Better XML support.
- Support LLVM 3.6.
- Exception class is now shown on unhandled exceptions
- The following types are now disallowed in generics (for now): Object, Value, Reference, Number, Int and Float.
- Lots of bug fixes, enhancements and optimizations.
- The
classmethod now works in all cases. You can now compare classes with==and ask theirhashvalue. - Block variables can now shadow local variables.
Range(B, E)is nowRange(T).- Added
Number::[]. Now you can doInt64[1, 2, 3]instead of[1_i64, 2_i64, 3_u64]. - Better detection of nilable instance variables, and better error messages too.
- Added
Crypto::Blowfish(thanks @akaufmann) - Added
Matrix(thanks @Exilor) - Added
CallConventionattribute forfuns. - Macros: added
constantsso you can inspect a type's constants at compile time. - Macros: added
methods, which lists a type's methods (without including supertypes). - Macros: added
has_attribute?for enum types, so you can check if an enum has the Flags attribute on it. - Many more small additions and bug fixes.
- Same as 0.5.10
- Note: This release makes core, breaking changes to the language, and doesn't work out of the box with its accompanying standard library. Use 0.6.0 instead.
- Improved error messages related to nilable instance variables.
- The magic variables
$~and$?are now method-local and concurrent-safe. Tupleis now correctly considered a structPointeris now correctly considered a struct- Renamed
FunctiontoProc
Randomis now a module, with static methods that default to theRandom::MT19937class.- Added
Random::ISAACengine (thanks @ysbaddaden!) - Added
String#size(thanks @zamith!) - Added
limitto allString#splitvariants (thanks @jhass!) - Raising inside a Thread is now rescued and re-raised on join (thanks @jhass!)
- Added
pathoption to Projectfile forcrystal deps(thanks @naps62!) - Many fixes towards making Crystal work on linux 32 bits.
- Huge refactors, additions and improvements for sockets: Socket, IPSocket, TCPSocket, TCPServer, UDPSocket, UNIXSocket, UNIXServer (thanks @ysbaddaden!)
- Allow regex with empty spaces in various places.
- Added
HTML.escape(String)(thanks @naps62!) - Added support for
%w[...],%w{...},%w<...>as alternatives to%w(...). Same goes for%i(...)(thanks @zamith!) - Added
Enumerable#min_of,Enumerable#max_ofandEnumerable#minmax_of,Enumerable#to_h,Dir.chdirandNumber#fdiv(thanks @jhass!) - Added
String#match,String#[],String#[]?andMatchData#[]?related to regexes (thanks @jhass!) - Allow
T::Barwhen T is a generic type argument. - Added
subclassesandall_subclassesin macros. - Now you can invoke
to_sandinspecton C structs and unions, making debugging C bindings much easier! - Added
#to_fand#to_itoTimeandTimeSpan(thanks @epitron!) - Added
IO.select(thanks @jhass!) - Now you can use
ifdefinside C structs and unions. - Added
includeinside C structs, to include other struct fields (useful for composition and avoiding an explicit indirection). - Added
Char#in_set?,String#count,String#deleteandString#squeeze(thanks @jhass!) - Added
-D flagoption to the compiler to set compile-time flags to use inifdef. - More support for forward declarations inside C libs.
- Rewritten some
Functionprimitives in Crystal itself, and added methods for obtaining the pointer and closure data, as well as for recreating a function from these. - Added a
Loggerclass (thanks @ysbaddaden!) - Lots of bugs fixed.
- Added
RandomandRandom::MT19937(Mersenne Twister) classes (thanks @rhysd). - Docs: removed automatic linking. To link to classes and methods surround with backticks.
- Fixed #328:
!=bug.
- Fixed:
doccommand had some hardcoded paths and didn't work - Added:
private defat the top-level of a file is only available inside that file
- Added a
crystal doccommand to automatically generate documentation for a project using Markdown syntax. The style is still ugly but it's quite functional. Now we only need to start documenting things :-) - Removed the old
@:attribute syntax. - Fixed #311: Issues with invoking lib functions in other ways (thanks @scidom).
- Fixed #314: NoReturn information is not lazy.
- Fixed #317: Fixes in UTF-8 encoding/decoding (thanks @yous).
- Fixed #319: Unexpected EOF (thanks @Exilor).
{{yield}}inside macros now preserve the yielded node location, leading to much better error messages.- Added
Float#nan?,Float#infinite?andFloat#finite?. - Many other bug fixes and improvements.
- Removed
srcand crystal compilerlibsdirectory from CRYSTAL_PATH. - Several bug fixes.
- (breaking change)
require "foo"always looks up inCRYSTAL_PATH.require "./foo"looks up relative to the requiring file. - (breaking change) Renamed
JsontoJSON,XmltoXMLandYamltoYAMLto follow a convention. - (breaking change) To use HTTP types do, for example,
require "http/client"instead of the oldrequire "net/http". - Added
alias_methodmacro (thanks @Exilor and @jtomschroeder). - Added some
Complexnumber methods and many math methods, refactors and specs (thanks @scidom). - Inheriting generic classes is now possible.
- Creating arrays of generic types (i.e.:
[] of Thread) is now possible. - Allow using an alias in a block type (i.e.:
alias F = Int32 ->,&block : F). json_mappingmacro supports a simpler syntax:json_mapping({key1: Type1, key2: Type2}).- Spec: added
be_a(type)matcher. - Spec: added
be > ...and similar matchers for>=,<and<=. - Added
File::file?andFile::directory?. - CSV parser can parse from String or IO.
- When invoking the compiler like this:
crystal foo.cr -o foothebuildcommand is assumed instead ofrun. - Added short symbol notation for methods that are operators (i.e.
:+,:*,:[], etc.). - Added
TimeSpan#ago,TimeSpan#from_now,MonthSpan#agoandMonthSpan#from_now.
- Spec: when a
shouldorshould_notfail, the filename and line number, including the source's line, is included in the error message. - Spec: added
-lswitch to be able to run a spec defined in a line. - Added
crystal spec file:line - Properties (property, setter, getter) can now be restricted to a type with the syntax
property name :: Type. - Enums can be used outside
lib. They inheritEnum, can have methods and can be marked with @[Flags]. - Removed the distinction between
libenums and regular enums. - Fixed: it was incorrectly possible to define
class,def, etc. inside a call block. - The syntax for specifying the base type of an enum,
enum Name < BaseTypehas been deprecated. Useenum Name : BaseType. - Added
Array#<=>and make it comparable to other arrays.
- New command line interface to the compiler (
crystal build ...,crystal run ...,crystal spec, etc.). The default is to compiler and run a program. crystal evalwithout arguments reads from standard input.- Added preliminar
crystal depscommand. __FILE__,__DIR__and__LINE__, when used as def default arguments, resolve to the caller location (similar to D and Swift)- Allow
asto determine a type even if the casted value doesn't have a type yet. - Added
is_a?in macros. The check is against an AST node name. For examplenode.is_a?(HashLiteral). - Added
emit_nullproperty tojson_mapping. - Added
converterproperty tojson_mapping. - Added
ppin macros. - Added
to_pretty_json. - Added really basic
CSV.parse. - Added
Regex.escape. - Added
String#scan. - Added
-eswitch to spec, to run specs that match a pattern. - Added
--fail-fastswtich to spec. - Added
HTTPClient#basic_auth. - Added
DeclareVar,DefandArgmacro methods. - Added
TimeandTimeSpanstructs.TimeWithZonewill come later. - Added
Array#fill(thanks @Exilor). - Added
Array#uniq. - Optimized
File.read_lines. - Allow any expression inside
{% ... %}so that you can intepret code without outputting the result. - Allow
\at the end of a line. - Allow using
ifandunlessinside macro expressions. - Allow marking a
fun/defas@[Raises](useful when a function can potentially raise from a callback). - Allow procs are now considered
@[Raises]. OAuth2::Clientsupports getting an access token via authorization code or refresh token.- Consecutive string literals are automatically concatenated by the parser as long as there is a
\with a newline between them. - Many bug fixes.
- Added json_mapping macro.
- Added Signal module.
- Added Tempfile class.
- Enhanced HTTP::Client.
- Added OAuth::Consumer.
- Added OAuth2::Client.
- Added OpenSSL::HMAC.
- Added SecureRandom.
- New syntax for array/hash-like classes. For example:
Set {1, 2, 3}andHTTP::Headers {"content-type": "text/plain"}. These just create the type and use<<or[]=. - Optimized Json parsing performance.
- Added a CSV builder.
- XML reader can parse from an IO.
- Added
Dir::globandDir::Entries(thanks @jhass) - Allow
ensureas an expression suffix. - Fixed #219: Proc type is not inferred when passing to library fun and the return type doesn't match.
- Fixed #224: Class#new doesn't pass a block.
- Fixed #225: ICE when comparing void to something.
- Fixed #227: Nested captured block looses scope and crashes compiler.
- Fixed #228: Macro expansion doesn't retain symbol escaping as needed.
- Fixed #229: Can't change block context if defined within module context.
- Fixed #230: Type interference breaks equality operator.
- Fixed #233: Incorrect
no block givenmessage with new. - Other bug fixes.
- String overhaul, and optimizations
- Define backtick (`) for command execution.
- Allow string literals as keys in hash literals:
{"foo": "bar"} # :: Hash(String, String) - Allow
ifdefas a suffix. - Integer division by zero raises a
DivisionByZeroexception. - Link attributes are now only processed if a lib function is used.
- Removed the
type Name : Typesyntax (usetype Name = Typeinstead). - Removed the
lib Lib("libname"); endsyntax. Use@[Link]attribute instead. - Fixed some
requireissues. - String representation includes length.
- Upgraded to LLVM 3.5.
- Fixed #193: allow initializing an enum value with another's one.
- The
recordmacro is now variadic, so instead ofrecord Vec3, [x, y, z]writerecord Vec3, x, y, z. - The
def_equals,def_hashanddef_equals_and_hashmacros are now variadic. - The
property,getterandsettermacros are now variadic. - All String methods are now UTF-8 aware.
String#lengthreturns the number of characters, whileString#bytesizereturn the number of bytes (previouslylengthreturned the number of bytes andbytesizedidn't exist).String#[](index)now returns aCharinstead of anUInt8, where index is counted in characters. There's alsoString#byte_at(index).- Removed the
\xescape sequence in char and string literals. Use\uinstead. initializemethods are now protected.- Added
IO#gets_to_end. - Added backticks (
...) and%x(...)for command execution. - Added
%r(...)for regular expression literals. - Allow interpolations in regular expresion literals.
- Compiling with
--releasesets areleaseflag that you can test withifdef. - Allow passing splats to C functions
- A C type can now be declared like
type Name = Type(type Name : Typewill be deprecated). - Now a C struct/union type can be created with named arguments.
- New attributes syntax:
@[Attr(...)] instead of@:Attr. The old syntax will be deprecated in a future release. - New link syntax for C libs:
@[Link("name")](usesnameaspkg-config nameif available or-lnameinstead),@[Link(ldflags: "...")]to pass raw flags to the linker,@[Link("name", static: true)]to try to find a static library first, and@[Link(framework: "AppKit")](for Mac OSX). - Added an
execmethod to execute shell commands. Added thesystemandbackticksimilar to Ruby ones. - Added
be_truthyandbe_falseyspec matchers. AddedArray#zipwithout a block. (thanks @mjgpy3) - Added
getter?andproperty?macros to create methods that end with?. - Added a
CGImodule. - The compiler now only depends on
ccfor compiling (removed dependency tollc,opt,llvm-disandclang). - Added
IO#tty?. - Some bug fixes.
- Reverted a commit that introduced random crashes.
- Fixed #187: mixing
yieldandblock.callcrashes the compiler. - Added
\uunicode escape sequences inside strings and chars (similar to Ruby).\xwill be deprecated as it can generate strings with invalid UTF-8 byte sequences. - Added
String#chars. - Fixed: splats weren't working in
initialize. - Added the
privateandprotectedvisibility modifiers, with the same semantics as Ruby. The difference is that you must place them before adefor a macro call. - Some bug fixes.
- Fixed #185:
-eflag stopped working. - Added a
@lengthcompile-time variable available inside tuples that allows to do loop unrolling. - Some bug fixes.
- Support splats in macros.
- Support splats in defs and calls.
- Added named arguments.
- Renamed the
make_named_tuplemacro torecord. - Added
def_equals,def_hashanddef_equals_and_hashmacros to generate them from a list of fields. - Added
Slice(T), which is a struct having a pointer and a length. Use this in IO for a safe API. - Some
StaticArrayfixes and enhancements.
- (breaking change) Removed the special
->operator for pointers of structs/unions: instead offoo->barusefoo.value.bar; instead offoo->bar = 1usefoo.value.bar = 1. - Added
colorizefile that provides methods to easily output bash colors. - Now you can use modules as generic type arguments (for example, do
x = [] of IO). - Added SSL sockets. Now HTTP::Server implements HTTPS.
- Macros have access to constants and types.
- Allow iterating a range in macros with
for. - Use cpu cycle counter to initialize random.
method_missingnow works in generic types.- Fixed #154: bug, constants are initialized before global variables.
- Fixed #168: incorrect type inference of instance variables if not assigned in superclass.
- Fixed #169:
responds_to?wasn't working with generic types. - Fixed #171: ensure blocks are not executed if the rescue block returns from a def.
- Fixed #175: invalid code generated when using with/yield with structs.
- Fixed some parser issues and other small issues.
- Allow forward struct/union declarations in libs.
- Added
String#replace(Regex, String) - Added a
Box(T)class, useful for boxing value types to pass them to C asVoid*.
- Fixed #165: restrictions with generic types didn't work for hierarchy types.
- Allow using a single underscore in restrictions, useful for matching against an n-tuple or an n-function where you don't care about the types (e.g.:
def foo(x : {_, _}). - Added a
generate_hashmacro that generates ahashmethods based on some AST nodes. - Added very basic
previous_def: similar tosuper, but uses the previous definition of a method. Useful to decorate existing methods (similar toalias_method_chain). For now the method's type restrictions must match for a previous definition to be found. - Made the compiler a bit faster
- Added
envin macros, to fetch an environment value. Returns a StringLiteral if found or NilLiteral if not. - Make
return 1, 2be the same asreturn {1, 2}. Same goes withbreakandnext. - Added
Pointer#as_enumerable(size : Int)to create anEnumerablefrom a Pointer with an associated size, with zero overhead. Some methods removed fromPointer:each,map,to_a,index. - Added
StaticArray::new,StaticArray::new(value),StaticArray::new(&block),StaticArray#shuffle!andStaticArray#map!. - Faster
Char#to_s(io : IO)
- Allow implicit conversion to C types by defining a
to_unsafemethod. This removed the hardcoded rule for converting aStringtoUInt8*and also allows passing anArray(T)to an argument expectingPointer(T). - Fixed
.is_a?(Class)not working (#162) - Attributes are now associated to AST nodes in the semantic pass, not during parsing. This allows macros to generate attributes that will be attached to subsequent expressions.
- (breaking change) Make ENV#[] raise on missing key, and added ENV#[]?
- (breaking change) Macro defs are now written like
macro def name(args) : ReturnTypeinstead ofdef name(args) : ReturnType, which was a bit confusing.
- Integer literals without a suffix are inferred to be Int32, Int64 or UInt64 depending on their value.
- Check that integer literals fit into their types.
- Put back
Int#to_s(radix : Int)(was renamed toto_s_in_basein the previous release) by also specifying a restriction inInt#to_s(io : IO). - Added
expect_raisesmacros in specs
- (breaking change) Replaced
@nameinside macros with@class_name. - (breaking change) Instance variables inside macros now don't have the
@symbols in their names.
- Added
Array#each_index - Optimized
String#*for the case when the string has length one. - Use
GC.malloc_atomicfor String and String::Buffer (as they don't contain internal pointers.) - Added a
PointerAppenderstruct to easily append to aPointerwhile counting at the same time (thanks @kostya for the idea). - Added a
Base64module (thanks @kostya) - Allow default arguments in macros
- Allow invoking
newon a function type. For example:alias F = Int32 -> Int32; f = F.new { |x| x + 1 }; f.call(2) #=> 3. - Allow ommiting function argument types when invoking C functions that accept functions as arguments.
- Renamed
@nameto@class_nameinside macros.@namewill be deprecated in the next version. - Added IO#read_fully
- Macro hooks:
inherited,includedandextended method_missingmacro- Added
{{ raise ... }}inside macros to issue a compile error. - Started JSON serialization and deserialization
- Now
at_exithandlers are run when you invokeexit - Methods can be marked as abstract
- New convention for
to_sandinspect: you must override them receiving an IO object - StringBuilder and StringBuffer have been replaced by StringIO
-
Removed icr (a REPL): it is abandoned for the moment because it was done in a hacky, non-reliable way
-
Added very basic
String#underscoreandString#camelcase. -
The parser generates string literals out of strings with interpolated string literals. For example,
"#{__DIR__}/foo"is interpolated at compile time and generates a string literal with the full path, since__DIR__is just a (special) string literal. -
(breaking change) Now macro nodes are always pasted as is. If you want to generate an id use
{{var.id}}.Previously, a code like this:
macro foo(name) def {{name}}; end end foo :hello foo "hello" foo hello
generated this:
def hello; end def hello; end def hello; end
With this change, it generates this:
def :hello; end def "hello"; end def hello; end
Now, to get an identifier out of a symbol literal, string literal or a name, use id:
macro foo(name) def {{name.id}}; end end
Although it's longer to type, the implicit "id" call was sometimes confusing. Explicit is better than implicit.
Invoking
idon any other kind of node has no effect on the pasted result. -
Allow escaping curly braces inside macros with
\{. This allows defining macros that, when expanded, can contain other macro expressions. -
Added a special comment-like pragma to change the lexer's filename, line number and colum number.
# foo.cr a = 1 #<loc:"bar.cr",12,24>b = 2 c = 3
In the previous example,
b = 2(and the rest of the file) is considered as being parsed from filebar.crat line 12, column 24. -
Added a special
runcall inside macros. This compiles and executes another Crystal program and pastes its output into the current program.As an example, consider this program:
# foo.cr {{ run("my_program", 1, 2, 3) }}
Compiling
foo.crwill, at compile-time, compilemy_program.crand execute it with arguments1 2 3. The output of that execution is pasted intofoo.crat that location. -
Added ECR (Embedded Crystal) support. This is implemented using the special
runmacro call.A small example:
# template.ecr Hello <%= @msg %>
# foo.cr require "ecr/macros" class HelloView def initialize(@msg) end # This generates a to_s method with the contents of template.ecr ecr_file "template.ecr" end view = HelloView.new "world!" view.to_s #=> "Hello world!"
The nice thing about this is that, using the
#<loc...>pragma for specifying the lexer's location, if you have a syntax/semantic error in the template the error points to the template :-)
- First official release