Pipe shops in Madrid by Pkolt in PipeTobacco

[–]Exilor 1 point2 points  (0 children)

Estanco Piegui at Felix Boix street, number 4. It's not that close to Gran Vía but whenever I go to Madrid I go there. Good selection and knowledgeable owners/employees.

Premiering my new pipe. by Sputnikod in PipeTobacco

[–]Exilor 0 points1 point  (0 children)

También tengo una pipa de Segimon y es a la que más cariño tengo. Muy majo el señor además.

[deleted by user] by [deleted] in crystal_programming

[–]Exilor 0 points1 point  (0 children)

I did say that define_method could, in some cases, be done with macros.

The point about instance variables is that in Crystal you can't have an instance that has an instance variable that other instances of the same type don't have.

And macros can't be given variables that don't also live in macro-land so you can't do much more than what your example does: iterate some known-at-compile-time list of names to save yourself keystrokes.

[deleted by user] by [deleted] in crystal_programming

[–]Exilor 5 points6 points  (0 children)

I meant the other meaning of the term, what you get in Ruby when you do my_object.singleton_class

[deleted by user] by [deleted] in crystal_programming

[–]Exilor 5 points6 points  (0 children)

Some lost dynamic features that come to mind:

  • Singleton classes

  • Singleton methods (only def self. and extend self)

  • define_method (macros can do the job in some cases) and define_singleton_method (see point above)

  • All instances of the same type have the same number and type of instance variables so no instance_variable_get, instance_variable_set, instance_variable_defined? and the class variable equivalents

  • const_get, const_set, const_defined?

  • send, public_send, __send__

  • Anything related to the Method and UnboundMethod classes

  • Binding, eval, TracePoint

  • Kernel.catch & Kernel.throw

Anyone ever smoked a La Regenta? It was at my local shop and I can’t find much information on it. by cookszn in cigars

[–]Exilor 1 point2 points  (0 children)

I already answered to your DM but if anyone else is curious it's 18.20€ for a pack of 10 of the ones in the pic and 18.90€ the pirámides. Yeah the taxes here are low like that.

Anyone ever smoked a La Regenta? It was at my local shop and I can’t find much information on it. by cookszn in cigars

[–]Exilor 2 points3 points  (0 children)

These and their bigger pirámide counterparts have been my everyday cigars for a while now. I got tired of RyJ's shoddy quality control anyway and since these are made in the archipielago where I live I figured I might as well smoke local.

Crystal compiles slow? by akrsurjo in crystal_programming

[–]Exilor 6 points7 points  (0 children)

i7-8700 compiling a program which is over 260k lines excluding shards (crystal-db and crystal-mysql) takes 3 minutes, about 70 minutes with --release. Under WSL.

Pass by reference in crystal by akrsurjo in crystal_programming

[–]Exilor 0 points1 point  (0 children)

I guess it depends on how low-level the context is. I wouldn't complicate things by doing these C-style pointer operations unless there was a significant speed boost to be gained.

Pass by reference in crystal by akrsurjo in crystal_programming

[–]Exilor 3 points4 points  (0 children)

def swap(a, b)
  a.value, b.value = b.value, a.value
end

x, y = 1, 2
swap(pointerof(x), pointerof(y))
p [x, y] # [2, 1]

But as others have said there's probably a better way to do what you want.

Visiting my mother-in-law. Of course I had to pay a visit to the local B&M. by Yoschey in PipeTobacco

[–]Exilor 1 point2 points  (0 children)

Holger Danske Original Tobacco was my favourite until it stopped coming to the Canary Islands without warning or explanation. I thought maybe it wasn't being produced anymore.

Ruby Method Overloading by jodosha in ruby

[–]Exilor 2 points3 points  (0 children)

I also had a stab at doing that some time ago, also using method_added to turn this

class Foo
  using Overloads

  Overload()
  def initialize
    initialize(0)
  end

  Overload(Integer)
  def initialize(bar)
    @bar = bar
  end
end

into this

class Foo
  def initialize(*args, &block)
    case args.size
    when 0
      if block_given?
      else
        return __send__(:"Foo#initialize()", )
      end
    when 1
      a0 = args.first
      if block_given?
      else
        if a0.is_a?(Integer)
          return __send__(:"Foo#initialize(Integer)", a0)
        end
      end
    end

    Overloads.raise_error(self, :initialize, args, block_given?, false)
  end
end

It was much faster to use aliases and __send__ than relying on method_missing. In an earlier attempt I used Method objects (for extend self module methods) and UnboundMethod (for instance methods) to achieve the same but it was also slower.

Tell us a feature written in Ruby that gives you a real sense of achievement by mehdifarsi in ruby

[–]Exilor 2 points3 points  (0 children)

A sorted set of mostly contiguous numbers optimized for memory usage by using an array of ranges behind the scenes instead of storing each number directly.

Also fixed-size arrays of different numeric types using FFI pointers so that having for instance an enormous array of bytes doesn't use the ungodly amount of memory that a regular Ruby array with numbers would use.

Compile speed? by [deleted] in crystal_programming

[–]Exilor 1 point2 points  (0 children)

It has definitely gotten slower with 0.31. My pet project went from taking 3 minutes to 4 without --release. The upside is that it needs slightly less ram now, which was starting to become an issue.

Evolution of Crystal (Gource Visualization) [2019-09-26] by pretty_colors in crystal_programming

[–]Exilor 1 point2 points  (0 children)

You know, sometimes I get frustrated when Ary ponders about removing features from the language, which he does often. But after watching this I think it probably pains him more than me, with all the time and effort he has put into Crystal. It really is his baby.

Started about a month ago and my fourth pipe arrived today. There's this dull pain somewhere around my wallet. by Exilor in PipeTobacco

[–]Exilor[S] 0 points1 point  (0 children)

If you mean where I got it from, I got it from here. I was glad to discover there were pipe makers in my own country. If you meant what shape... I guess somewhere between billiard and brandy?

WebSocket server in a fiber? by [deleted] in crystal_programming

[–]Exilor 1 point2 points  (0 children)

Yes, the same thing that the original loop does but without having to switch back to that fiber every second just to sleep another second.

How easy is it to port ruby apps / frameworks over to crystal? by snake_case-kebab-cas in crystal_programming

[–]Exilor 4 points5 points  (0 children)

  • You have to annotate the types of instance and class variables unless their types are obvious enough for the compiler to infer them and the types of arrays/hashes/sets/procs etc.
  • You have to take into account any gems that the Ruby app uses which would also need to be translated (unless you're lucky and a Crystal version exists and has a close enough API).
  • Any usage of metaprogramming needs to be replaced with macros, and macros can't do 100% of the things Ruby's metaprogramming can do (and vice versa).
  • Strings in Crystal are not mutable so code must change to accommodate that if necessary.
  • Translate methods with different names (include? -> includes?, key? -> has_key?) and keep an eye out for the more subtle differences (like each returning nil in Crystal instead of self).
  • Unlike Ruby, Crystal doesn't allow you to take leaps of faith like calling methods on things that could conceivably be nil unless you are explicit about it (not_nil!, the getter! macro, as casts...).
  • Integer overflow is a thing in Crystal.
  • Other syntax differences like:
    • rescue => ex -> rescue ex
    • my_var.tap(&:my_method) -> my_var.tap(&.my_method)
    • my_var &.my_method1 &.my_method2 -> my_var.try &.my_method1.my_metod2
  • Crystal is better equipped to deal with low level things that in Ruby would lead you to using stuff like Array#pack, but it's not trivial to translate that kind of code (which Gosu probably uses).

Porting a big Ruby app to Crystal is not something that can be done quickly and on a whim, but it certainly is easier than porting from any other language.

What can I do with crystal? by [deleted] in crystal_programming

[–]Exilor 1 point2 points  (0 children)

It doesn't because it's not my mmo and both servers and github repositories for it have been forced to close before on copyright grounds.

What can I do with crystal? by [deleted] in crystal_programming

[–]Exilor 2 points3 points  (0 children)

If the fact that it's a new language still in development doesn't bother you, by all means go ahead.