Suppress value dump in Swift REPL

When using Swift REPL every time I assign a value to a variable, it displays the entire dump of the value. I want to suppress this because when it is an instance of a large structure, it completely deletes the previous lines.

  1 > let a = SomethingComplex()

a: SomethingComplex = {
  list = 3 values {
    [0] = {
      edges = 4 values {
        [0] = {
          id = 1
          from = 0x0000000100506110 {
            edges = 4 values {
              [0] = {
                id = 3
                from = 0x0000000100506a50 {
                  edges = 4 values {
                    [0] = {
                      id = 5
                      from = 0x0000000100506820 {...}
                      to = 0x0000000100506a50 {...}
                    }
  .
  .
  .

Is there any way to suppress this?

+4
source share
1 answer

Swift REPL runs in the context of the lldb debugger and, by default, prints the values ​​of the variables declared in the expression. This is controlled by the lldb variable.

  print-decls - If true, LLDB will print the values ​​of
                                  variables declared in an expression.
                                  Currently only supported in the REPL
                                  (default: true).

( :set list Swift REPL, lldb-.)

, false. ( , lldb):

$ swift
Welcome to Apple Swift version 4.1 (swiftlang-902.0.48 clang-902.0.39.1). Type :help for assistance.

  1> struct SomethingComplex { let x = 1; let y = 2 }
  2> let a = SomethingComplex()
a: SomethingComplex = {
  x = 1
  y = 2
}
  3> :set set print-decls false
  3> let b = SomethingComplex()
  4>  
+2

Source: https://habr.com/ru/post/1695769/


All Articles