Skip to content

Commit 9e6229d

Browse files
committed
Revert block function feature.
1 parent dc84524 commit 9e6229d

File tree

18 files changed

+37
-265
lines changed

18 files changed

+37
-265
lines changed

core/source/Array.mint

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module Array {
2323
Array.all(["hello", "mint"], (str : String) { String.size(str) > 3 }) == true
2424
*/
2525
fun all (array : Array(item), function : Function(item, Bool)) : Bool {
26-
reduce(array, true) { |memo : Bool, val : item| memo && function(val) }
26+
reduce(array, true, (memo : Bool, val : item) { memo && function(val) })
2727
}
2828

2929
/*
@@ -52,12 +52,13 @@ module Array {
5252
Array.compact([Maybe.Just("A"), Maybe.Nothing]) == ["A"]
5353
*/
5454
fun compact (array : Array(Maybe(item))) : Array(item) {
55-
reduce(array, []) { |memo : Array(item), item : Maybe(item)|
56-
case item {
57-
Just(value) => Array.push(memo, value)
58-
Nothing => memo
59-
}
60-
}
55+
reduce(array, [],
56+
(memo : Array(item), item : Maybe(item)) : Array(item) {
57+
case item {
58+
Just(value) => Array.push(memo, value)
59+
Nothing => memo
60+
}
61+
})
6162
}
6263

6364
/*
@@ -95,7 +96,7 @@ module Array {
9596
Array.delete(["a", "b", "c", "a"], "a") == ["b", "c"]
9697
*/
9798
fun delete (array : Array(item), what : item) : Array(item) {
98-
reject(array) { |item : item| item == what }
99+
reject(array, (item : item) { item == what })
99100
}
100101

101102
/*
@@ -713,7 +714,7 @@ module Array {
713714
Array.sum([]) == 0
714715
*/
715716
fun sum (array : Array(Number)) : Number {
716-
Array.reduce(array, 0) { |memo : Number, item : Number| item + memo }
717+
reduce(array, 0, (memo : Number, item : Number) : Number { item + memo })
717718
}
718719

719720
/*

core/source/CSV.mint

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -256,23 +256,25 @@ module CSV {
256256
lineEnding : CSV.LineEnding = CSV.LineEnding.Unix
257257
) : String {
258258
rows
259-
|> Array.map() { |row : Array(String)|
260-
Array.map(row) { |field : String|
261-
// Double quotes need to be escaped with an extra doublequote.
262-
let value =
263-
String.replace(field, "\"", "\"\"")
264-
265-
// If the string contains a separator, \n, \r\n or " it needs to
266-
// be escaped by wrapping in double quotes.
267-
if String.contains(value, separator) || String.contains(value, "\n") || String.contains(
268-
value, "\"") {
269-
"\"#{value}\""
270-
} else {
271-
value
272-
}
273-
}
274-
}
275-
|> Array.map() { |row : Array(String)| String.join(row, separator) }
259+
|> Array.map(
260+
(row : Array(String)) {
261+
Array.map(row,
262+
(field : String) {
263+
// Double quotes need to be escaped with an extra doublequote.
264+
let value =
265+
String.replace(field, "\"", "\"\"")
266+
267+
// If the string contains a separator, \n, \r\n or " it needs to
268+
// be escaped by wrapping in double quotes.
269+
if String.contains(value, separator) || String.contains(value, "\n") || String.contains(
270+
value, "\"") {
271+
"\"#{value}\""
272+
} else {
273+
value
274+
}
275+
})
276+
})
277+
|> Array.map((row : Array(String)) { String.join(row, separator) })
276278
|> String.join(
277279
case lineEnding {
278280
Windows => "\r\n"

spec/compilers/call_with_block_function

Lines changed: 0 additions & 22 deletions
This file was deleted.

spec/examples/call

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -292,15 +292,3 @@ component Main {
292292
<div>"Hello World!"</div>
293293
}
294294
}
295-
--------------------------------------------------------------------------------
296-
component Main {
297-
fun renderTest (block : Function(String, Html)) {
298-
block("TEST")
299-
}
300-
301-
fun render : Html {
302-
renderTest() { |x : String|
303-
<div>x</div>
304-
}
305-
}
306-
}

spec/formatters/call_with_block

Lines changed: 0 additions & 21 deletions
This file was deleted.

spec/formatters/call_with_nested_block

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/ast/block_function.cr

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/ast/call.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Mint
22
class Ast
33
class Call < Node
4-
getter arguments, expression, await, block
4+
getter arguments, expression, await
55

66
def initialize(@arguments : Array(Field),
77
@from : Parser::Location,

src/compilers/inline_function.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Mint
22
class Compiler
3-
def compile(node : Ast::InlineFunction | Ast::BlockFunction) : Compiled
3+
def compile(node : Ast::InlineFunction) : Compiled
44
compile node do
55
body =
66
case item = node.body

src/formatter.cr

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ module Mint
8989

9090
# The possibilities on how to format groups.
9191
enum Behavior
92-
BreakAllButFirst
9392
BreakNotFits
9493
BreakAll
9594
Block
@@ -150,7 +149,6 @@ module Mint
150149
def format_arguments(
151150
nodes : Array(Ast::Node), *,
152151
empty_parenthesis = true,
153-
block = false,
154152
) : Nodes
155153
return empty_parenthesis ? ["()"] of Node : [] of Node if nodes.empty?
156154

@@ -164,19 +162,12 @@ module Mint
164162
end
165163
end || Behavior::BreakNotFits
166164

167-
ends =
168-
if block
169-
{"|", "|"}
170-
else
171-
{"(", ")"}
172-
end
173-
174165
[
175166
Group.new(
176167
items: nodes.map(&->format(Ast::Node)),
177168
behavior: behavior,
169+
ends: {"(", ")"},
178170
separator: ",",
179-
ends: ends,
180171
pad: false),
181172
] of Node
182173
end

0 commit comments

Comments
 (0)